From 8968dfeb96c0334c273860ca64103b6fe7028ac4 Mon Sep 17 00:00:00 2001 From: Thanh Ha Date: Sat, 9 Oct 2021 10:33:11 -0400 Subject: [PATCH] Refactor: Resolve F811 and E712 and E501 in tests - 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 --- tests/test_deploy.py | 90 +++++++++++++++++++++------------------- tests/test_release_docker_hub.py | 6 +-- 2 files changed, 50 insertions(+), 46 deletions(-) diff --git a/tests/test_deploy.py b/tests/test_deploy.py index 1fd1ab5a..168257c2 100644 --- a/tests/test_deploy.py +++ b/tests/test_deploy.py @@ -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): - +

404 - Not Found

@@ -380,16 +376,21 @@ def test_get_node_from_xml(): """Test extracting from xml.""" document = """\ - Demo slideshow - Slide title - This is a demo - Of a program for processing slides - - - Another demo slide432It is important - To have more than - one slide - + Demo slideshow + + + Slide title + This is a demo + Of a program for processing slides + + + + Another demo slide + 432 + It is important + To have more than + one slide + """ assert deploy_sys._get_node_from_xml(document, "stagedRepositoryId") == "432" @@ -684,7 +685,10 @@ def test_nexus_stage_repo_create(responses, mocker): - +

405 - HTTP method POST is not supported by this URL

diff --git a/tests/test_release_docker_hub.py b/tests/test_release_docker_hub.py index f86bae21..7daa81ab 100644 --- a/tests/test_release_docker_hub.py +++ b/tests/test_release_docker_hub.py @@ -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 == "[" -- 2.16.6