1
- from random import choice
2
1
import unittest
3
2
4
3
from requests .exceptions import HTTPError
5
4
6
5
from pulp_smash import api , config , utils
7
- from pulp_smash .pulp3 .constants import ARTIFACTS_PATH , REPO_PATH
8
- from pulp_smash .pulp3 .utils import (
9
- delete_orphans ,
10
- gen_repo ,
11
- get_content ,
12
- sync ,
13
- )
14
-
15
- from pulp_python .tests .functional .constants import (
16
- PYTHON_CONTENT_PATH ,
17
- PYTHON_FIXTURES_URL ,
18
- PYTHON_REMOTE_PATH ,
19
- PYTHON_WHEEL_URL ,
20
- )
21
- from pulp_python .tests .functional .utils import (
22
- gen_python_package_attrs ,
23
- gen_python_remote ,
24
- skip_if
25
- )
6
+ from pulp_smash .pulp3 .constants import ARTIFACTS_PATH
7
+ from pulp_smash .pulp3 .utils import delete_orphans
8
+
9
+ from pulp_python .tests .functional .constants import PYTHON_CONTENT_PATH , PYTHON_WHEEL_URL
10
+ from pulp_python .tests .functional .utils import gen_python_package_attrs , skip_if
26
11
from pulp_python .tests .functional .utils import set_up_module as setUpModule # noqa:F401
27
12
28
13
@@ -33,6 +18,7 @@ class ContentUnitTestCase(unittest.TestCase):
33
18
This test targets the following issues:
34
19
35
20
* `Pulp #2872 <https://pulp.plan.io/issues/2872>`_
21
+ * `Pulp #3445 <https://pulp.plan.io/issues/3445>`_
36
22
* `Pulp Smash #870 <https://github.com/PulpQE/pulp-smash/issues/870>`_
37
23
"""
38
24
@@ -97,8 +83,9 @@ def test_03_partially_update(self):
97
83
98
84
"""
99
85
attrs = gen_python_package_attrs (self .artifact )
100
- with self .assertRaises (HTTPError ):
86
+ with self .assertRaises (HTTPError ) as exc :
101
87
self .client .patch (self .content_unit ['_href' ], attrs )
88
+ self .assertEqual (exc .exception .response .status_code , 405 )
102
89
103
90
@skip_if (bool , 'content_unit' , False )
104
91
def test_03_fully_update (self ):
@@ -109,47 +96,16 @@ def test_03_fully_update(self):
109
96
110
97
"""
111
98
attrs = gen_python_package_attrs (self .artifact )
112
- with self .assertRaises (HTTPError ):
99
+ with self .assertRaises (HTTPError ) as exc :
113
100
self .client .put (self .content_unit ['_href' ], attrs )
101
+ self .assertEqual (exc .exception .response .status_code , 405 )
114
102
103
+ @skip_if (bool , 'content_unit' , False )
104
+ def test_04_delete (self ):
105
+ """Attempt to delete a content unit using HTTP DELETE.
115
106
116
- class DeleteContentUnitRepoVersionTestCase (unittest .TestCase ):
117
- """
118
- Test whether content unit used by a repo version can be deleted.
119
-
120
- This test targets the following issues:
121
-
122
- * `Pulp #3418 <https://pulp.plan.io/issues/3418>`_
123
- * `Pulp Smash #900 <https://github.com/PulpQE/pulp-smash/issues/900>`_
124
- """
125
-
126
- def test_all (self ):
127
- """
128
- Test whether content unit used by a repo version can be deleted.
129
-
130
- Do the following:
131
-
132
- 1. Sync content to a repository.
133
- 2. Attempt to delete a content unit present in a repository version.
134
- Assert that a HTTP exception was raised.
135
- 3. Assert that number of content units present on the repository
136
- does not change after the attempt to delete one content unit.
137
-
107
+ This HTTP method is not supported and a HTTP exception is expected.
138
108
"""
139
- cfg = config .get_config ()
140
- client = api .Client (cfg , api .json_handler )
141
-
142
- body = gen_python_remote (PYTHON_FIXTURES_URL )
143
- remote = client .post (PYTHON_REMOTE_PATH , body )
144
- self .addCleanup (client .delete , remote ['_href' ])
145
-
146
- repo = client .post (REPO_PATH , gen_repo ())
147
- self .addCleanup (client .delete , repo ['_href' ])
148
-
149
- sync (cfg , remote , repo )
150
-
151
- repo = client .get (repo ['_href' ])
152
- content = get_content (repo )
153
- with self .assertRaises (HTTPError ):
154
- client .delete (choice (content )['_href' ])
155
- self .assertEqual (len (content ), len (get_content (repo )))
109
+ with self .assertRaises (HTTPError ) as exc :
110
+ self .client .delete (self .content_unit ['_href' ])
111
+ self .assertEqual (exc .exception .response .status_code , 405 )
0 commit comments