Test: Improve unit test for nexus 02/68402/2
authorEric Ball <eball@linuxfoundation.org>
Fri, 30 Jul 2021 22:45:05 +0000 (15:45 -0700)
committerEric Ball <eball@linuxfoundation.org>
Mon, 2 Aug 2021 22:11:15 +0000 (15:11 -0700)
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 <eball@linuxfoundation.org>
tests/fixtures/nexus/staging_activities_releasing.xml [new file with mode: 0644]
tests/test_nexus.py

diff --git a/tests/fixtures/nexus/staging_activities_releasing.xml b/tests/fixtures/nexus/staging_activities_releasing.xml
new file mode 100644 (file)
index 0000000..4022a3c
--- /dev/null
@@ -0,0 +1,55 @@
+<list>
+    <stagingActivity>
+        <name>open</name>
+        <started>2021-01-01T01:01:00.000Z</started>
+        <stopped>2021-01-01T01:01:01.000Z</stopped>
+        <events>
+            <stagingActivityEvent>
+                <timestamp>2021-01-01T01:01:01.000Z</timestamp>
+                <name>repositoryCreated</name>
+                <severity>0</severity>
+                <properties>
+                    <stagingProperty>
+                        <name>id</name>
+                        <value>test-release-repo</value>
+                    </stagingProperty>
+                </properties>
+            </stagingActivityEvent>
+        </events>
+    </stagingActivity>
+    <stagingActivity>
+        <name>close</name>
+        <started>2021-01-01T01:01:02.000Z</started>
+        <stopped>2021-01-01T01:01:03.000Z</stopped>
+        <events>
+            <stagingActivityEvent>
+                <timestamp>2021-01-01T01:01:02.000Z</timestamp>
+                <name>repositoryClosed</name>
+                <severity>0</severity>
+                <properties>
+                    <stagingProperty>
+                        <name>id</name>
+                        <value>test-release-repo</value>
+                    </stagingProperty>
+                </properties>
+            </stagingActivityEvent>
+        </events>
+    </stagingActivity>
+    <stagingActivity>
+       <name>release</name>
+       <started>2021-01-01T01:01:04.000Z</started>
+       <events>
+           <stagingActivityEvent>
+               <timestamp>2021-01-01T01:01:04.000Z</timestamp>
+               <name>repositoryReleased</name>
+               <severity>0</severity>
+               <properties>
+                   <stagingProperty>
+                       <name>id</name>
+                       <value>test-release-repo</value>
+                   </stagingProperty>
+               </properties>
+           </stagingActivityEvent>
+       </events>
+   </stagingActivity>
+</list>
index 5887eda..88a55e5 100644 (file)
@@ -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)