From 84603977e9ebf18bf228638de9acc6122980043b Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 18 Mar 2022 13:17:03 +0300 Subject: Delete "app" import in MR * test/requests/test-website.py: Delete "from wqflask import app". This has the undesired effect of starting an instance of Genenetwork2. --- test/requests/test-website.py | 1 - 1 file changed, 1 deletion(-) (limited to 'test') diff --git a/test/requests/test-website.py b/test/requests/test-website.py index d619a7d5..ff6d2bd5 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -14,7 +14,6 @@ import link_checker import sys # Imports for integration tests -from wqflask import app from test_login_local import TestLoginLocal from test_login_orcid import TestLoginOrcid from test_login_github import TestLoginGithub -- cgit v1.2.3 From 5e0894778d1c6734e5c728328ed0950a42b8c883 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 18 Mar 2022 13:18:24 +0300 Subject: Delete deprecated modules * test/requests/test-website: These imports were deleted in an earlier PR here: --- test/requests/test-website.py | 5 ----- 1 file changed, 5 deletions(-) (limited to 'test') diff --git a/test/requests/test-website.py b/test/requests/test-website.py index ff6d2bd5..85174408 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -14,11 +14,6 @@ import link_checker import sys # Imports for integration tests -from test_login_local import TestLoginLocal -from test_login_orcid import TestLoginOrcid -from test_login_github import TestLoginGithub -from test_registration import TestRegistration -from test_forgot_password import TestForgotPassword from unittest import TestSuite, TextTestRunner, TestLoader print("Mechanical Rob firing up...") -- cgit v1.2.3 From 5171b3b08efcc7839e3d6c67cabb8f9831767b78 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 18 Mar 2022 13:31:21 +0300 Subject: Remove outdated integration tests on different login mechanisms * test/requests/test-website.py: Delete parser option "-i" for running integration tests. (integration_tests): Delete it. (integration_suite): Ditto. (run_integration_tests): Ditto. * test/requests/test_registration.py: Delete it. --- test/requests/test-website.py | 24 ------------------------ test/requests/test_registration.py | 35 ----------------------------------- 2 files changed, 59 deletions(-) delete mode 100644 test/requests/test_registration.py (limited to 'test') diff --git a/test/requests/test-website.py b/test/requests/test-website.py index 85174408..8b35c8ec 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -35,33 +35,12 @@ def print_help(args_obj, parser): def dummy(args_obj, parser): print("Not implemented yet.") -def integration_tests(args_obj, parser): - gn2_url = args_obj.host - run_integration_tests(gn2_url, es_url) def initTest(klass, gn2_url, es_url): loader = TestLoader() methodNames = loader.getTestCaseNames(klass) return [klass(mname, gn2_url, es_url) for mname in methodNames] -def integration_suite(gn2_url, es_url): - test_cases = [ - TestRegistration - , TestLoginLocal - , TestLoginGithub - , TestLoginOrcid - , TestForgotPassword - ] - the_suite = TestSuite() - for case in test_cases: - the_suite.addTests(initTest(case, gn2_url, es_url)) - return the_suite - -def run_integration_tests(gn2_url, es_url): - runner = TextTestRunner() - runner.run(integration_suite(gn2_url, es_url)) - - desc = """ This is Mechanical-Rob - an automated web server tester for Genenetwork.org @@ -95,9 +74,6 @@ parser.add_argument("-m", "--mapping", dest="accumulate" , action="store_const", const=check_mapping, default=print_help , help="Checks for mapping.") -parser.add_argument("-i", "--integration-tests", dest="accumulate" - , action="store_const", const=integration_tests, default=print_help - , help="Runs integration tests.") args = parser.parse_args() diff --git a/test/requests/test_registration.py b/test/requests/test_registration.py deleted file mode 100644 index 5d08bf58..00000000 --- a/test/requests/test_registration.py +++ /dev/null @@ -1,35 +0,0 @@ -import sys -import requests - -class TestRegistration(ParametrizedTest): - - - def testRegistrationPage(self): - data = { - "email_address": "test@user.com", - "full_name": "Test User", - "organization": "Test Organisation", - "password": "test_password", - "password_confirm": "test_password" - } - requests.post(self.gn2_url+"/n/register", data) - response = self.es.search( - index="users" - , doc_type="local" - , body={ - "query": {"match": {"email_address": "test@user.com"}}}) - self.assertEqual(len(response["hits"]["hits"]), 1) - - -def main(gn2, es): - import unittest - suite = unittest.TestSuite() - suite.addTest(TestRegistration(methodName="testRegistrationPage", gn2_url=gn2, es_url=es)) - runner = unittest.TextTestRunner() - runner.run(suite) - -if __name__ == "__main__": - if len(sys.argv) < 3: - raise Exception("Required arguments missing") - else: - main(sys.argv[1], sys.argv[2]) -- cgit v1.2.3 From 13d00e885600157cc253e9d03f26e712fed17346 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 18 Mar 2022 13:34:12 +0300 Subject: Apply "python-black" on file * test/requests/test-website.py: Run "black test/requests/test test-website.py". --- test/requests/test-website.py | 84 ++++++++++++++++++++++++++++++------------- 1 file changed, 60 insertions(+), 24 deletions(-) (limited to 'test') diff --git a/test/requests/test-website.py b/test/requests/test-website.py index 8b35c8ec..71055fca 100755 --- a/test/requests/test-website.py +++ b/test/requests/test-website.py @@ -18,6 +18,7 @@ from unittest import TestSuite, TextTestRunner, TestLoader print("Mechanical Rob firing up...") + def run_all(args_obj, parser): print("") print("Running all tests.") @@ -29,9 +30,11 @@ def run_all(args_obj, parser): check_mapping(args_obj, parser) # TODO: Add other functions as they are created. + def print_help(args_obj, parser): print(parser.format_help()) + def dummy(args_obj, parser): print("Not implemented yet.") @@ -41,6 +44,7 @@ def initTest(klass, gn2_url, es_url): methodNames = loader.getTestCaseNames(klass) return [klass(mname, gn2_url, es_url) for mname in methodNames] + desc = """ This is Mechanical-Rob - an automated web server tester for Genenetwork.org @@ -49,30 +53,62 @@ parser = argparse.ArgumentParser(description=desc) parser.add_argument("--fail", help="Fail and stop on any error", action="store_true") -parser.add_argument("-d", "--database", metavar="DB", type=str - , default="db_webqtl_s" - , help="Use database (default db_webqtl_s)") - -parser.add_argument("host", metavar="HOST", type=str - , default="http://localhost:5003" - , help="The url to the web server") - -parser.add_argument("-a", "--all", dest="accumulate", action="store_const" - , const=run_all, default=print_help - , help="Runs all tests.") - -parser.add_argument("-l", "--link-checker", dest="accumulate" - , action='store_const', const=check_links, default=print_help - , help="Checks for dead links.") - -parser.add_argument("-f", "--main-functionality", dest="accumulate" - , action='store_const', const=check_main_web_functionality - , default=print_help - , help="Checks for main web functionality.") - -parser.add_argument("-m", "--mapping", dest="accumulate" - , action="store_const", const=check_mapping, default=print_help - , help="Checks for mapping.") +parser.add_argument( + "-d", + "--database", + metavar="DB", + type=str, + default="db_webqtl_s", + help="Use database (default db_webqtl_s)", +) + +parser.add_argument( + "host", + metavar="HOST", + type=str, + default="http://localhost:5003", + help="The url to the web server", +) + +parser.add_argument( + "-a", + "--all", + dest="accumulate", + action="store_const", + const=run_all, + default=print_help, + help="Runs all tests.", +) + +parser.add_argument( + "-l", + "--link-checker", + dest="accumulate", + action="store_const", + const=check_links, + default=print_help, + help="Checks for dead links.", +) + +parser.add_argument( + "-f", + "--main-functionality", + dest="accumulate", + action="store_const", + const=check_main_web_functionality, + default=print_help, + help="Checks for main web functionality.", +) + +parser.add_argument( + "-m", + "--mapping", + dest="accumulate", + action="store_const", + const=check_mapping, + default=print_help, + help="Checks for mapping.", +) args = parser.parse_args() -- cgit v1.2.3