Skip to content

Commit

Permalink
Update tests to not rely on version always incrementing
Browse files Browse the repository at this point in the history
  • Loading branch information
dkliban committed Nov 13, 2019
1 parent 832e236 commit 25d0d20
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGES/3308.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated tests to support repository version not incrementing when content hasn't changed.
11 changes: 3 additions & 8 deletions pulp_rpm/tests/functional/api/test_download_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,8 @@ def do_sync(self, download_policy):
4. Assert that repository version is not None.
5. Assert that the correct number of possible units to be downloaded
were shown.
6. Sync the remote one more time in order to create another repository
version.
7. Assert that repository version is different from the previous one.
8. Assert that the same number of units are shown, and after the
second sync no extra units should be shown, since the same remote
was synced again.
6. Sync the remote one more time.
7. Assert that repository version is the same as the previous latest version.
"""
repo = self.client.post(RPM_REPO_PATH, gen_repo())
self.addCleanup(self.client.delete, repo['pulp_href'])
Expand Down Expand Up @@ -102,9 +98,8 @@ def do_sync(self, download_policy):
sync(self.cfg, remote, repo)
repo = self.client.get(repo['pulp_href'])

self.assertNotEqual(latest_version_href, repo['latest_version_href'])
self.assertEqual(latest_version_href, repo['latest_version_href'])
self.assertDictEqual(get_content_summary(repo), RPM_FIXTURE_SUMMARY)
self.assertDictEqual(get_added_content_summary(repo), {})

def do_publish(self, download_policy):
"""Publish repository synced with lazy ``download_policy``."""
Expand Down
2 changes: 1 addition & 1 deletion pulp_rpm/tests/functional/api/test_publish.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_all(self):
for rpm_content in get_content(repo)[RPM_PACKAGE_CONTENT_NAME]:
self.client.post(
urljoin(repo['pulp_href'], 'modify/'),
{'add_content_units': [rpm_content['pulp_href']]}
{'remove_content_units': [rpm_content['pulp_href']]}
)
version_hrefs = tuple(ver['pulp_href'] for ver in get_versions(repo))
non_latest = choice(version_hrefs[:-1])
Expand Down
24 changes: 8 additions & 16 deletions pulp_rpm/tests/functional/api/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def test_rpm(self):
5. Assert that the correct number of units were added and are present
in the repo.
6. Sync the remote one more time.
7. Assert that repository version is different from the previous one.
8. Assert that the same number of are present and that no units were
added.
7. Assert that repository version is the same as the previous one.
"""
repo = self.client.post(RPM_REPO_PATH, gen_repo())
self.addCleanup(self.client.delete, repo['pulp_href'])
Expand Down Expand Up @@ -98,9 +96,7 @@ def test_rpm(self):
repo = self.client.get(repo['pulp_href'])

# Check that nothing has changed since the last sync.
self.assertNotEqual(latest_version_href, repo['latest_version_href'])
self.assertDictEqual(get_content_summary(repo), RPM_FIXTURE_SUMMARY)
self.assertDictEqual(get_added_content_summary(repo), {})
self.assertEqual(latest_version_href, repo['latest_version_href'])


class KickstartSyncTestCase(unittest.TestCase):
Expand Down Expand Up @@ -135,9 +131,8 @@ def test_rpm_kickstart(self):
5. Assert that the correct number of units were added and are present
in the repo.
6. Sync the remote one more time.
7. Assert that repository version is different from the previous one.
8. Assert that the same number of are present and that no units were
added.
7. Assert that repository version is the same the previous one.
8. Assert that the same number of packages are present.
"""
repo = self.client.post(RPM_REPO_PATH, gen_repo())
self.addCleanup(self.client.delete, repo['pulp_href'])
Expand Down Expand Up @@ -173,11 +168,10 @@ def test_rpm_kickstart(self):
self.assertEqual(artifacts['count'], 3, artifacts)

# Check that nothing has changed since the last sync.
self.assertNotEqual(latest_version_href, repo['latest_version_href'])
self.assertEqual(latest_version_href, repo['latest_version_href'])
self.assertDictEqual(
get_content_summary(repo), RPM_KICKSTART_FIXTURE_SUMMARY
)
self.assertDictEqual(get_added_content_summary(repo), {})

def test_rpm_kickstart_on_demand(self):
"""Sync repositories with the rpm plugin.
Expand All @@ -200,9 +194,8 @@ def test_rpm_kickstart_on_demand(self):
5. Assert that the correct number of units were added and are present
in the repo.
6. Sync the remote one more time.
7. Assert that repository version is different from the previous one.
8. Assert that the same number of are present and that no units were
added.
7. Assert that repository version is the same as the previous one.
8. Assert that the same number of packages are present
"""
delete_orphans(self.cfg)
repo = self.client.post(RPM_REPO_PATH, gen_repo())
Expand Down Expand Up @@ -241,11 +234,10 @@ def test_rpm_kickstart_on_demand(self):
self.assertEqual(artifacts['count'], 0, artifacts)

# Check that nothing has changed since the last sync.
self.assertNotEqual(latest_version_href, repo['latest_version_href'])
self.assertEqual(latest_version_href, repo['latest_version_href'])
self.assertDictEqual(
get_content_summary(repo), RPM_KICKSTART_FIXTURE_SUMMARY
)
self.assertDictEqual(get_added_content_summary(repo), {})


class FileDescriptorsTestCase(unittest.TestCase):
Expand Down

0 comments on commit 25d0d20

Please sign in to comment.