Refactor: Resolve F811 and E712 and E501 in tests 61/68961/1
authorThanh Ha <zxiiro@gmail.com>
Sat, 9 Oct 2021 14:33:11 +0000 (10:33 -0400)
committerThanh Ha <zxiiro@gmail.com>
Sat, 9 Oct 2021 14:38:12 +0000 (10:38 -0400)
- E501 line too long
- E712 comparison to True should be 'if cond is True:' or 'if cond:'
- E712 comparison to False should be 'if cond is False:' or 'if not cond:'
- F811 redefinition of unused 'test_log_and_exit' from line 26

Change-Id: I896e994b26d62c7bdd85ca61ebf1b9d2df9e8b1e
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
tests/test_deploy.py
tests/test_release_docker_hub.py

index 1fd1ab5..168257c 100644 (file)
@@ -23,13 +23,6 @@ FIXTURE_DIR = os.path.join(
 )
 
 
-def test_log_and_exit():
-    """Test exit."""
-    with pytest.raises(SystemExit) as excinfo:
-        deploy_sys._log_error_and_exit("testmsg")
-    assert excinfo.type == SystemExit
-
-
 def test_format_url():
     """Test url format."""
     test_url = [
@@ -234,42 +227,42 @@ def test_remove_duplicates_and_sort():
         [
             [
                 "work/results/repo/repodata",
-                "work/results/repo/repodata/aef510f1572d6c8dd2d245640911934f51dca895d037dc137c3fe343b26ffe2a-other.sqlite.bz2",
-                "work/results/repo/repodata/8370c06da1e72e3186f5bd1bd7d04fb772883959de7973d9b6964322415f2f4f-other.xml.gz",
-                "work/results/repo/repodata/11299388173a685dda16ffa5e8e5993e8e32d513b1f93e11ae4bf38ac3623ff7-filelists.sqlite.bz2",
-                "work/results/repo/repodata/47b4a63805b1d3101f24281ed4237284c48ebc1d423092c742479438353e9a79-filelists.xml.gz",
-                "work/results/repo/repodata/224b2e07d395b282569c3ed5341f4fdc7ba2df3d9236117358d98e9f88667fdb-primary.sqlite.bz2",
-                "work/results/repo/repodata/ae2ac51511d3d99570bbe380deffd2e88043b93dafea81ece1ebae7b6dbb9f35-primary.xml.gz",
+                "work/results/repo/repodata/aef510f1572d6c8dd2d245640911934f51dca895d037dc137c3fe343b26ffe2a-other.sqlite.bz2",  # noqa
+                "work/results/repo/repodata/8370c06da1e72e3186f5bd1bd7d04fb772883959de7973d9b6964322415f2f4f-other.xml.gz",  # noqa
+                "work/results/repo/repodata/11299388173a685dda16ffa5e8e5993e8e32d513b1f93e11ae4bf38ac3623ff7-filelists.sqlite.bz2",  # noqa
+                "work/results/repo/repodata/47b4a63805b1d3101f24281ed4237284c48ebc1d423092c742479438353e9a79-filelists.xml.gz",  # noqa
+                "work/results/repo/repodata/224b2e07d395b282569c3ed5341f4fdc7ba2df3d9236117358d98e9f88667fdb-primary.sqlite.bz2",  # noqa
+                "work/results/repo/repodata/ae2ac51511d3d99570bbe380deffd2e88043b93dafea81ece1ebae7b6dbb9f35-primary.xml.gz",  # noqa
                 "work/results/repo/repodata/repomd.xml",
                 "work/results/src_repo",
                 "work/results/src_repo/product-manifest-95-1.el7.centos.ta.src.rpm",
                 "work/results/src_repo/repodata",
-                "work/results/src_repo/repodata/103971d7e000d6d79bfdce8a6ee2acb9d9f9ea70db181d6399ebe7fc1df60cbb-other.sqlite.bz2",
-                "work/results/src_repo/repodata/2fadeaa73aa6313afb359828628bc661c4fc686d82a0e2acba6d93bdd3bd32b8-other.xml.gz",
-                "work/results/src_repo/repodata/28c69dfda86e6dd2d612e21efad415feff1ef44718a475b58d4e2e345fc22f82-filelists.sqlite.bz2",
-                "work/results/src_repo/repodata/a19a91350de47d15d147c12aebe1aa4682e4733edc14719de09eaee8793c1080-filelists.xml.gz",
-                "work/results/src_repo/repodata/6cc8efe401cb22a8e07934d93ef6214fef91175130b2a8c1286161a7bf504a5a-primary.sqlite.bz2",
-                "work/results/src_repo/repodata/43cc7ddec49d87af8e8b78c6ec2c3c8c9bf57d8a0723e3950266cd0440147af4-primary.xml.gz",
+                "work/results/src_repo/repodata/103971d7e000d6d79bfdce8a6ee2acb9d9f9ea70db181d6399ebe7fc1df60cbb-other.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/2fadeaa73aa6313afb359828628bc661c4fc686d82a0e2acba6d93bdd3bd32b8-other.xml.gz",  # noqa
+                "work/results/src_repo/repodata/28c69dfda86e6dd2d612e21efad415feff1ef44718a475b58d4e2e345fc22f82-filelists.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/a19a91350de47d15d147c12aebe1aa4682e4733edc14719de09eaee8793c1080-filelists.xml.gz",  # noqa
+                "work/results/src_repo/repodata/6cc8efe401cb22a8e07934d93ef6214fef91175130b2a8c1286161a7bf504a5a-primary.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/43cc7ddec49d87af8e8b78c6ec2c3c8c9bf57d8a0723e3950266cd0440147af4-primary.xml.gz",  # noqa
                 "work/results/src_repo/repodata/repomd.xml",
             ],
             [
                 "work/results/repo/repodata",
-                "work/results/repo/repodata/11299388173a685dda16ffa5e8e5993e8e32d513b1f93e11ae4bf38ac3623ff7-filelists.sqlite.bz2",
-                "work/results/repo/repodata/224b2e07d395b282569c3ed5341f4fdc7ba2df3d9236117358d98e9f88667fdb-primary.sqlite.bz2",
-                "work/results/repo/repodata/47b4a63805b1d3101f24281ed4237284c48ebc1d423092c742479438353e9a79-filelists.xml.gz",
-                "work/results/repo/repodata/8370c06da1e72e3186f5bd1bd7d04fb772883959de7973d9b6964322415f2f4f-other.xml.gz",
-                "work/results/repo/repodata/ae2ac51511d3d99570bbe380deffd2e88043b93dafea81ece1ebae7b6dbb9f35-primary.xml.gz",
-                "work/results/repo/repodata/aef510f1572d6c8dd2d245640911934f51dca895d037dc137c3fe343b26ffe2a-other.sqlite.bz2",
+                "work/results/repo/repodata/11299388173a685dda16ffa5e8e5993e8e32d513b1f93e11ae4bf38ac3623ff7-filelists.sqlite.bz2",  # noqa
+                "work/results/repo/repodata/224b2e07d395b282569c3ed5341f4fdc7ba2df3d9236117358d98e9f88667fdb-primary.sqlite.bz2",  # noqa
+                "work/results/repo/repodata/47b4a63805b1d3101f24281ed4237284c48ebc1d423092c742479438353e9a79-filelists.xml.gz",  # noqa
+                "work/results/repo/repodata/8370c06da1e72e3186f5bd1bd7d04fb772883959de7973d9b6964322415f2f4f-other.xml.gz",  # noqa
+                "work/results/repo/repodata/ae2ac51511d3d99570bbe380deffd2e88043b93dafea81ece1ebae7b6dbb9f35-primary.xml.gz",  # noqa
+                "work/results/repo/repodata/aef510f1572d6c8dd2d245640911934f51dca895d037dc137c3fe343b26ffe2a-other.sqlite.bz2",  # noqa
                 "work/results/repo/repodata/repomd.xml",
                 "work/results/src_repo",
                 "work/results/src_repo/product-manifest-95-1.el7.centos.ta.src.rpm",
                 "work/results/src_repo/repodata",
-                "work/results/src_repo/repodata/103971d7e000d6d79bfdce8a6ee2acb9d9f9ea70db181d6399ebe7fc1df60cbb-other.sqlite.bz2",
-                "work/results/src_repo/repodata/28c69dfda86e6dd2d612e21efad415feff1ef44718a475b58d4e2e345fc22f82-filelists.sqlite.bz2",
-                "work/results/src_repo/repodata/2fadeaa73aa6313afb359828628bc661c4fc686d82a0e2acba6d93bdd3bd32b8-other.xml.gz",
-                "work/results/src_repo/repodata/43cc7ddec49d87af8e8b78c6ec2c3c8c9bf57d8a0723e3950266cd0440147af4-primary.xml.gz",
-                "work/results/src_repo/repodata/6cc8efe401cb22a8e07934d93ef6214fef91175130b2a8c1286161a7bf504a5a-primary.sqlite.bz2",
-                "work/results/src_repo/repodata/a19a91350de47d15d147c12aebe1aa4682e4733edc14719de09eaee8793c1080-filelists.xml.gz",
+                "work/results/src_repo/repodata/103971d7e000d6d79bfdce8a6ee2acb9d9f9ea70db181d6399ebe7fc1df60cbb-other.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/28c69dfda86e6dd2d612e21efad415feff1ef44718a475b58d4e2e345fc22f82-filelists.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/2fadeaa73aa6313afb359828628bc661c4fc686d82a0e2acba6d93bdd3bd32b8-other.xml.gz",  # noqa
+                "work/results/src_repo/repodata/43cc7ddec49d87af8e8b78c6ec2c3c8c9bf57d8a0723e3950266cd0440147af4-primary.xml.gz",  # noqa
+                "work/results/src_repo/repodata/6cc8efe401cb22a8e07934d93ef6214fef91175130b2a8c1286161a7bf504a5a-primary.sqlite.bz2",  # noqa
+                "work/results/src_repo/repodata/a19a91350de47d15d147c12aebe1aa4682e4733edc14719de09eaee8793c1080-filelists.xml.gz",  # noqa
                 "work/results/src_repo/repodata/repomd.xml",
             ],
         ],
@@ -346,7 +339,10 @@ def test_deploy_nexus_zip(cli_runner, datafiles, responses):
     <link rel="SHORTCUT ICON" href="https://nexus.opendaylight.org/favicon.ico"/>
     <![endif]-->
 
-    <link rel="stylesheet" href="https://nexus.opendaylight.org/static/css/Sonatype-content.css?2.14.7-01" type="text/css" media="screen" title="no title" charset="utf-8">
+    <link type="text/css" media="screen" charset="utf-8" rel="stylesheet"
+        title="no title"
+        href="https://nexus.opendaylight.org/static/css/Sonatype-content.css?2.14.7-01"
+    />
   </head>
   <body>
     <h1>404 - Not Found</h1>
@@ -380,16 +376,21 @@ def test_get_node_from_xml():
     """Test extracting from xml."""
     document = """\
         <slideshow>
-        <title>Demo slideshow</title>
-        <slide><title>Slide title</title>
-        <point>This is a demo</point>
-        <point>Of a program for processing slides</point>
-        </slide>
-
-        <slide><title>Another demo slide</title><stagedRepositoryId>432</stagedRepositoryId><point>It is important</point>
-        <point>To have more than</point>
-        <point>one slide</point>
-        </slide>
+            <title>Demo slideshow</title>
+
+            <slide>
+                <title>Slide title</title>
+                <point>This is a demo</point>
+                <point>Of a program for processing slides</point>
+            </slide>
+
+            <slide>
+                <title>Another demo slide</title>
+                <stagedRepositoryId>432</stagedRepositoryId>
+                <point>It is important</point>
+                <point>To have more than</point>
+                <point>one slide</point>
+            </slide>
         </slideshow>
         """
     assert deploy_sys._get_node_from_xml(document, "stagedRepositoryId") == "432"
@@ -684,7 +685,10 @@ def test_nexus_stage_repo_create(responses, mocker):
                 <!--[if IE]>
                 <link rel="SHORTCUT ICON" href="http://192.168.1.26:8081/nexus/favicon.ico"/>
                 <![endif]-->
-                <link rel="stylesheet" href="http://192.168.1.26:8081/nexus/static/css/Sonatype-content.css?2.14.10-01" type="text/css" media="screen" title="no title" charset="utf-8">
+                <link rel="stylesheet" type="text/css" media="screen" charset="utf-8"
+                    title="no title"
+                    href="http://192.168.1.26:8081/nexus/static/css/Sonatype-content.css?2.14.10-01"
+                />
             </head>
             <body>
                 <h1>405 - HTTP method POST is not supported by this URL</h1>
index f86bae2..7daa81a 100644 (file)
@@ -110,7 +110,7 @@ def test_tag_class_repository_exist():
     repo_from_file = False
     rdh.initialize(org)
     tags = rdh.TagClass(org, repo, repo_from_file)
-    assert tags.repository_exist == True
+    assert tags.repository_exist
 
 
 @pytest.mark.datafiles(
@@ -213,14 +213,14 @@ class TestTagsRegExpClass:
         org = "onap"
         test_regexp_from_file = os.path.join(str(datafiles), "releasedockerhub_good_regexp")
         rdh.initialize(org, test_regexp_from_file)
-        assert rdh.validate_regexp() == True
+        assert rdh.validate_regexp()
         assert rdh.VERSION_REGEXP == r"^\d+.\d+"
 
     def test_tag_class_manual_version_regexp_str_from_file_invalid(self, datafiles):
         org = "onap"
         test_regexp_from_file = os.path.join(str(datafiles), "releasedockerhub_bad_regexp")
         rdh.initialize(org, test_regexp_from_file)
-        assert rdh.validate_regexp() == False
+        assert not rdh.validate_regexp()
         assert rdh.VERSION_REGEXP == "["