From: Eric Ball Date: Fri, 30 Jul 2021 22:45:05 +0000 (-0700) Subject: Test: Improve unit test for nexus X-Git-Tag: v0.35.6~1^2 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F02%2F68402%2F2;p=releng%2Flftools.git Test: Improve unit test for nexus When waiting for a repo to complete releasing, a more realistic "activity" return is to have the "release" status in place, but without the "stopped" property (which is not added until the repo is finished releasing). This improved unit test would have caught the bug addressed by commit e083184d. Change-Id: I0827cdaad07a8fb94d0f266dc8e53fd69c4aab2d Signed-off-by: Eric Ball --- diff --git a/tests/fixtures/nexus/staging_activities_releasing.xml b/tests/fixtures/nexus/staging_activities_releasing.xml new file mode 100644 index 00000000..4022a3c1 --- /dev/null +++ b/tests/fixtures/nexus/staging_activities_releasing.xml @@ -0,0 +1,55 @@ + + + open + 2021-01-01T01:01:00.000Z + 2021-01-01T01:01:01.000Z + + + 2021-01-01T01:01:01.000Z + repositoryCreated + 0 + + + id + test-release-repo + + + + + + + close + 2021-01-01T01:01:02.000Z + 2021-01-01T01:01:03.000Z + + + 2021-01-01T01:01:02.000Z + repositoryClosed + 0 + + + id + test-release-repo + + + + + + + release + 2021-01-01T01:01:04.000Z + + + 2021-01-01T01:01:04.000Z + repositoryReleased + 0 + + + id + test-release-repo + + + + + + diff --git a/tests/test_nexus.py b/tests/test_nexus.py index 5887eda4..88a55e5c 100644 --- a/tests/test_nexus.py +++ b/tests/test_nexus.py @@ -65,13 +65,14 @@ def test_release_staging_repos(datafiles, responses, nexus2_obj_create, mock_get request_url = "{}/staging/bulk/promote".format(baseurl) closed_return = open("staging_activities_closed.xml", "r").read() + releasing_return = open("staging_activities_releasing.xml", "r").read() released_return = open("staging_activities_released.xml", "r").read() responses.add(responses.GET, activity_url, closed_return, status=200) responses.add(responses.POST, request_url, status=201) # While checking for the "release" activity, we return once without it in # order to exercise the code for "if not released". - responses.add(responses.GET, activity_url, closed_return, status=200) + responses.add(responses.GET, activity_url, releasing_return, status=200) responses.add(responses.GET, activity_url, released_return, status=200) cmd.release_staging_repos(repos, False)