Skip to content

Commit

Permalink
Reduce test assumptions
Browse files Browse the repository at this point in the history
The `test_acs_sync` needs to have orphans cleaned prior, but since it
was the first test typically it didn't show this problem before. Also we
shouldn't need to cleanup orphans after that test anymore either.

By not cleaning up orphans we now have to clean up orphans prior to at
least one other test. Also the test_auto_publish test had assumptions
that content was already available in the system so that test got
rewritten some.

[noissue]
  • Loading branch information
bmbouter committed Apr 8, 2022
1 parent d46e4d7 commit 02af125
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 1 addition & 5 deletions pulp_file/tests/functional/api/test_acs.py
Expand Up @@ -56,11 +56,6 @@ def setUpClass(cls):
cls.paths = ["goodpath/PULP_MANIFEST", "test", "whatever/test"]
delete_orphans()

@classmethod
def tearDownClass(cls):
"""Run orphan cleanup."""
delete_orphans()

def _create_acs(self, name="file_acs", paths=None, remote_url=FILE_FIXTURE_MANIFEST_URL):
remote = self.file_remote_api.create(gen_file_remote(remote_url, policy="on_demand"))
self.addCleanup(self.file_remote_api.delete, remote.pulp_href)
Expand Down Expand Up @@ -90,6 +85,7 @@ def test_path_validation(self):

def test_acs_sync(self):
"""Test syncing from an ACS."""
delete_orphans()
repo = self.repo_api.create(gen_repo())
self.addCleanup(self.repo_api.delete, repo.pulp_href)

Expand Down
20 changes: 15 additions & 5 deletions pulp_file/tests/functional/api/test_auto_publish.py
Expand Up @@ -3,8 +3,8 @@
import unittest

from pulp_smash import config
from pulp_smash.pulp3.bindings import monitor_task
from pulp_smash.pulp3.utils import gen_repo, download_content_unit
from pulp_smash.pulp3.bindings import delete_orphans, monitor_task
from pulp_smash.pulp3.utils import delete_version, download_content_unit, gen_repo

from pulp_file.tests.functional.utils import gen_file_client, gen_file_remote
from pulp_file.tests.functional.utils import set_up_module as setUpModule # noqa:F401
Expand Down Expand Up @@ -38,6 +38,7 @@ def setUpClass(cls):

def setUp(self):
"""Create remote, repo, and distribution."""
delete_orphans()
self.remote = self.remote_api.create(gen_file_remote())
self.repo = self.repo_api.create(gen_repo(manifest=self.CUSTOM_MANIFEST, autopublish=True))
response = self.distributions_api.create(
Expand All @@ -52,7 +53,11 @@ def tearDown(self):
monitor_task(self.remote_api.delete(self.remote.pulp_href).task)
monitor_task(self.distributions_api.delete(self.distribution.pulp_href).task)

def test_01_sync(self):
def test_workflow(self):
self._sync()
self._modify()

def _sync(self):
"""Assert that syncing the repository triggers auto-publish and auto-distribution."""
self.assertEqual(self.publications_api.list().count, 0)
self.assertTrue(self.distribution.publication is None)
Expand Down Expand Up @@ -80,12 +85,17 @@ def test_01_sync(self):
self.assertEqual(len(task.created_resources), 0)
self.assertEqual(self.publications_api.list().count, 1)

def test_02_modify(self):
self.publications_api.delete(publication.pulp_href)
self.repo = self.repo_api.read(self.repo.pulp_href)
delete_version_task = delete_version(self.repo, version_href=self.repo.latest_version_href)
monitor_task(delete_version_task[0]["pulp_href"])

def _modify(self):
"""Assert that modifying the repository triggers auto-publish and auto-distribution."""
self.assertEqual(self.publications_api.list().count, 0)
self.assertTrue(self.distribution.publication is None)

# Modify the repository by adding a coment unit
# Modify the repository by adding a content unit
content = self.content_api.list().results[0].pulp_href
modify_response = self.repo_api.modify(
self.repo.pulp_href, {"add_content_units": [content]}
Expand Down

0 comments on commit 02af125

Please sign in to comment.