From 52071b11c0a92b772c59f3185a0929a5ec180348 Mon Sep 17 00:00:00 2001 From: Lukas Puehringer Date: Tue, 25 Feb 2020 12:28:00 +0100 Subject: [PATCH] Remove duplicate testing simple_server.py tests/simple_server.py was copied to tuf/scripts/ to "make testing easier" (cf84d3f51f1c7093d5f37e9caaaac10552cc9d66), although with the current test setup the original (and recently patched to fix an Windows/Py2 test issue) test simple_server.py can be used just as well. This commit: - removes tuf/scripts/simple_server.py Note: that version slightly differed from the original test server, probably due to demands by the linter that is only executed on the tuf core code and not on the tests. However, for the testing purposes of simple_server.py these changes (i.e., `SystemRandom()`, `if __name__ =='__main__':`) are not necessary. - updates the tests that used tuf.scripts.simple_server to instead use tests.simple_server, - updates setup.py to not install the simple_server module as script, when installing tuf, as it is only a testing script and not meant for end-user usage. Signed-off-by: Lukas Puehringer --- setup.py | 3 +-- tests/test_multiple_repositories_integration.py | 4 ++-- tests/test_updater.py | 12 ++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index b3d6099d56..9e598e100d 100755 --- a/setup.py +++ b/setup.py @@ -124,7 +124,6 @@ packages = find_packages(exclude=['tests']), scripts = [ 'tuf/scripts/repo.py', - 'tuf/scripts/client.py', - 'tuf/scripts/simple_server.py', + 'tuf/scripts/client.py' ] ) diff --git a/tests/test_multiple_repositories_integration.py b/tests/test_multiple_repositories_integration.py index 327d9dad36..aae18722b5 100755 --- a/tests/test_multiple_repositories_integration.py +++ b/tests/test_multiple_repositories_integration.py @@ -128,8 +128,8 @@ def setUp(self): while self.SERVER_PORT == self.SERVER_PORT2: self.SERVER_PORT2 = random.SystemRandom().randint(30000, 45000) - command = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT)] - command2 = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT2)] + command = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT)] + command2 = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT2)] self.server_process = subprocess.Popen(command, stderr=subprocess.PIPE, cwd=self.repository_directory) diff --git a/tests/test_updater.py b/tests/test_updater.py index 9f5c94d632..1fa8969819 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -98,7 +98,7 @@ def setUpClass(cls): # as a delegated role 'targets/role1', three target files, five key files, # etc. cls.SERVER_PORT = random.randint(30000, 45000) - command = ['python', '-m', 'tuf.scripts.simple_server', str(cls.SERVER_PORT)] + command = ['python', '-m', 'tests.simple_server', str(cls.SERVER_PORT)] cls.server_process = subprocess.Popen(command, stderr=subprocess.PIPE) logger.info('\n\tServer process started.') logger.info('\tServer process id: '+str(cls.server_process.pid)) @@ -1094,7 +1094,7 @@ def test_6_get_one_valid_targetinfo(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. SERVER_PORT = random.randint(30000, 45000) - command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)] + command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)] server_process = subprocess.Popen(command, stderr=subprocess.PIPE) # NOTE: Following error is raised if a delay is not long enough: @@ -1361,7 +1361,7 @@ def test_7_updated_targets(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. SERVER_PORT = random.randint(30000, 45000) - command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)] + command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)] server_process = subprocess.Popen(command, stderr=subprocess.PIPE) # NOTE: Following error is raised if a delay is not long enough to allow @@ -1493,7 +1493,7 @@ def test_8_remove_obsolete_targets(self): # The SimpleHTTPServer started in the setupclass has a tendency to # timeout in Windows after a few tests. SERVER_PORT = random.randint(30000, 45000) - command = ['python', '-m', 'tuf.scripts.simple_server', str(SERVER_PORT)] + command = ['python', '-m', 'tests.simple_server', str(SERVER_PORT)] server_process = subprocess.Popen(command, stderr=subprocess.PIPE) # NOTE: Following error is raised if a delay is not long enough to allow @@ -1877,8 +1877,8 @@ def setUp(self): self.SERVER_PORT = 30001 self.SERVER_PORT2 = 30002 - command = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT)] - command2 = ['python', '-m', 'tuf.scripts.simple_server', str(self.SERVER_PORT2)] + command = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT)] + command2 = ['python', '-m', 'tests.simple_server', str(self.SERVER_PORT2)] self.server_process = subprocess.Popen(command, stderr=subprocess.PIPE, cwd=self.repository_directory)