Test: Speed up Nexus tests 20/69720/3
authorEric Ball <eball@linuxfoundation.org>
Tue, 22 Feb 2022 18:58:04 +0000 (10:58 -0800)
committerEric Ball <eball@linuxfoundation.org>
Tue, 22 Feb 2022 20:57:57 +0000 (12:57 -0800)
By patching the sleep function, we can remove about 25 seconds of
pauses during unit testing of release_staging_repos method.

Issue: RELENG-4052
Change-Id: I8692c1183d70873348616435074b9b69193dda41
Signed-off-by: Eric Ball <eball@linuxfoundation.org>
tests/test_nexus.py

index 37a2e28..fbd4ce4 100644 (file)
@@ -56,7 +56,7 @@ def test_create_roles(datafiles, responses, nexus2_obj_create):
 
 
 @pytest.mark.datafiles(os.path.join(FIXTURE_DIR, "nexus"))
-def test_release_staging_repos(datafiles, responses, nexus2_obj_create, mock_get_credentials):
+def test_release_staging_repos(datafiles, responses, mocker, nexus2_obj_create, mock_get_credentials):
     """Test create_roles() method with good config."""
     os.chdir(str(datafiles))
     baseurl = "http://nexus.localhost/service/local"
@@ -68,6 +68,8 @@ def test_release_staging_repos(datafiles, responses, nexus2_obj_create, mock_get
     releasing_return = open("staging_activities_releasing.xml", "r").read()
     released_return = open("staging_activities_released.xml", "r").read()
 
+    mocker.patch.object(cmd, "sleep")
+
     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