Skip to content

Commit 006ee3b

Browse files
authored
Merge pull request #209 from dralley/master
Update smash tests
2 parents db0feb8 + 4e136cc commit 006ee3b

File tree

3 files changed

+51
-64
lines changed

3 files changed

+51
-64
lines changed

pulp_python/tests/functional/api/test_crud_content_unit.py

Lines changed: 17 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,13 @@
1-
from random import choice
21
import unittest
32

43
from requests.exceptions import HTTPError
54

65
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
2611
from pulp_python.tests.functional.utils import set_up_module as setUpModule # noqa:F401
2712

2813

@@ -33,6 +18,7 @@ class ContentUnitTestCase(unittest.TestCase):
3318
This test targets the following issues:
3419
3520
* `Pulp #2872 <https://pulp.plan.io/issues/2872>`_
21+
* `Pulp #3445 <https://pulp.plan.io/issues/3445>`_
3622
* `Pulp Smash #870 <https://github.com/PulpQE/pulp-smash/issues/870>`_
3723
"""
3824

@@ -97,8 +83,9 @@ def test_03_partially_update(self):
9783
9884
"""
9985
attrs = gen_python_package_attrs(self.artifact)
100-
with self.assertRaises(HTTPError):
86+
with self.assertRaises(HTTPError) as exc:
10187
self.client.patch(self.content_unit['_href'], attrs)
88+
self.assertEqual(exc.exception.response.status_code, 405)
10289

10390
@skip_if(bool, 'content_unit', False)
10491
def test_03_fully_update(self):
@@ -109,47 +96,16 @@ def test_03_fully_update(self):
10996
11097
"""
11198
attrs = gen_python_package_attrs(self.artifact)
112-
with self.assertRaises(HTTPError):
99+
with self.assertRaises(HTTPError) as exc:
113100
self.client.put(self.content_unit['_href'], attrs)
101+
self.assertEqual(exc.exception.response.status_code, 405)
114102

103+
@skip_if(bool, 'content_unit', False)
104+
def test_04_delete(self):
105+
"""Attempt to delete a content unit using HTTP DELETE.
115106
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.
138108
"""
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)

pulp_python/tests/functional/api/test_sync.py

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
2-
from pulp_smash import api, config, exceptions
3-
from pulp_smash.pulp3.constants import REPO_PATH
2+
from pulp_smash import api, cli, config, exceptions
3+
from pulp_smash.pulp3.constants import MEDIA_PATH, REPO_PATH
44
from pulp_smash.pulp3.utils import (
55
gen_repo,
66
get_added_content,
@@ -85,6 +85,37 @@ def test_sync(self):
8585
self.assertEqual(len(get_content(repo)), PYTHON_XS_PACKAGE_COUNT)
8686
self.assertEqual(len(get_added_content(repo)), 0)
8787

88+
def test_file_decriptors(self):
89+
"""Test whether file descriptors are closed properly.
90+
91+
This test targets the following issue:
92+
`Pulp #4073 <https://pulp.plan.io/issues/4073>`_
93+
94+
Do the following:
95+
1. Check if 'lsof' is installed. If it is not, skip this test.
96+
2. Create and sync a repo.
97+
3. Run the 'lsof' command to verify that files in the
98+
path ``/var/lib/pulp/`` are closed after the sync.
99+
4. Assert that issued command returns `0` opened files.
100+
"""
101+
cli_client = cli.Client(self.cfg, cli.echo_handler)
102+
103+
# check if 'lsof' is available
104+
if cli_client.run(('which', 'lsof')).returncode != 0:
105+
raise unittest.SkipTest('lsof package is not present')
106+
107+
repo = self.client.post(REPO_PATH, gen_repo())
108+
self.addCleanup(self.client.delete, repo['_href'])
109+
110+
remote = self.client.post(PYTHON_REMOTE_PATH, gen_python_remote())
111+
self.addCleanup(self.client.delete, remote['_href'])
112+
113+
sync(self.cfg, remote, repo)
114+
115+
cmd = 'lsof -t +D {}'.format(MEDIA_PATH).split()
116+
response = cli_client.run(cmd).stdout
117+
self.assertEqual(len(response), 0, response)
118+
88119

89120
class SyncInvalidURLTestCase(unittest.TestCase):
90121
"""Sync a repository with an invalid url on the Remote."""

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import setup, find_packages
44

55
requirements = [
6-
'pulpcore-plugin',
6+
'pulpcore-plugin==0.1.0b13',
77
'pkginfo',
88
'packaging',
99
]

0 commit comments

Comments
 (0)