Example #1
0
    def test_get(self):

        test_print("test_setup_get starting")

        # get the setup page and test it before setting up
        compare_get_request("setup")

        test_print("test_setup_get completed")
Example #2
0
def compare_request(requestcontent, request, requesttype, route_parameters,
                    file_path):
    """ Checks a request against previous results or saves the result of a request.
request is the endpoint requested, such as /setup
requesttype is the type of request performed- either 'get request' or 'post request'"""
    # if the global state is to replace all files, do that
    if args.resetalltests:
        with open(file_path, 'w') as rfile:
            rfile.write(requestcontent)
    elif requesttype[0:3] == "get" and request in args.resetgetrequests:
        test_print("resetting get request " + request +
                   " and saving to file " + file_path)
        with open(file_path, 'w') as rfile:
            rfile.write(requestcontent)

    elif requesttype[0:4] == "post" and request in args.resetpostrequests:
        test_print("resetting post request " + request +
                   " and saving to file " + file_path)
        with open(file_path, 'w') as rfile:
            rfile.write(requestcontent)

    else:

        olddata = None
        try:
            with open(file_path, "r") as oldfile:
                olddata = oldfile.read()
        except IOError as e:
            raise Exception("\n[synbiohub test] Could not open previous result for the " + \
                            requesttype + " " + request + ". If the saved result has not yet been created because it is a new page, please use --resetgetrequests [requests] or --resetpostrequests [requests] to create the file.") from e

        olddata = olddata.splitlines()
        newdata = requestcontent.splitlines()

        changes = difflib.unified_diff(olddata, newdata)

        # change list holds the strings to print in an error message
        changelist = [
            requesttype, " ", file_path,
            " did not match previous results. If you are adding changes to SynBioHub that change this page, please check that the page is correct and update the file using the command line argument --resetgetrequests [requests] and --resetpostrequests [requests].\nThe following is a diff of the new files compared to the old.\n"
        ]

        # temp variable to detect if we need to print the beginning of the error
        numofchanges = 0

        for c in changes:
            numofchanges += 1

            # print the diff
            changelist.append(c)
            changelist.append("\n")

        changelist.append(
            "\n Here is the last 50 lines of the synbiohub error log: \n")
        changelist.append(get_end_of_error_log(50))

        if numofchanges > 0:
            raise ValueError(''.join(changelist))
Example #3
0
 def save_authentication(self, request_result):
     soup = BeautifulSoup(request_result, 'lxml')
     ptag = soup.find_all('p')
     if len(ptag)!= 1:
         raise ValueError("Invalid login response received- multiple or no elements in p tag.")
     content = ptag[0].text
     self.login_authentication = content.strip()
     
     test_print("Logging in with authentication " + str(self.login_authentication))
Example #4
0
    def save_authentication(self, request_result):
        soup = BeautifulSoup(request_result, 'lxml')
        ptag = soup.find_all('p')
        if len(ptag) != 1:
            raise ValueError(
                "Invalid login response received- multiple or no elements in p tag."
            )
        content = ptag[0].text
        self.login_authentication = content.strip()

        test_print("Logging in with authentication " +
                   str(self.login_authentication))
Example #5
0
    def cleanup_check(self):
        nottestedcounter = 0

        for e in self.all_get_endpoints:
            if not e in self.tested_get_endpoints:
                nottestedcounter += 1
                test_print("Warning- get endpoint " + e + " was not tested.")

        for e in self.all_post_endpoints:
            if not e in self.tested_post_endpoints:
                nottestedcounter += 1
                test_print("Warning- post endpoint " + e + " was not tested.")

        for e in self.all_all_endpoints:
            if not e in self.tested_get_endpoints and not e in self.tested_post_endpoints:
                nottestedcounter += 1
                test_print("Warning- all endpoint " + e + " was not tested.")

        # test that all the endpoints that were tested were real endpoints
        for e in self.tested_get_endpoints:
            if not e in self.all_get_endpoints and not e in self.all_all_endpoints:
                raise Exception("Endpoint " + str(e) + " does not exist")

        for e in self.tested_post_endpoints:
            if not e in self.all_post_endpoints and not e in self.all_all_endpoints:
                raise Exception("Endpoint " + str(e) + " does not exist")

        if nottestedcounter != 0:
            test_print(str(nottestedcounter) + " endpoints not tested.")
Example #6
0
    def cleanup_check(self):
        nottestedcounter = 0

        for e in self.all_get_endpoints:
            if not e in self.tested_get_endpoints:
                nottestedcounter += 1
                test_print("Warning- get endpoint " + e + " was not tested.")

        for e in self.all_post_endpoints:
            if not e in self.tested_post_endpoints:
                nottestedcounter += 1
                test_print("Warning- post endpoint " + e + " was not tested.")

        for e in self.all_all_endpoints:
            if not e in self.tested_get_endpoints and not e in self.tested_post_endpoints:
                nottestedcounter += 1
                test_print("Warning- all endpoint " + e + " was not tested.")

        # test that all the endpoints that were tested were real endpoints
        for e in self.tested_get_endpoints:
            if not e in self.all_get_endpoints and not e in self.all_all_endpoints:
                raise Exception("Endpoint " + str(e) + " does not exist")

        for e in self.tested_post_endpoints:
            if not e in self.all_post_endpoints and not e in self.all_all_endpoints:
                raise Exception("Endpoint " + str(e) + " does not exist")

        if nottestedcounter != 0:
            test_print(str(nottestedcounter) + " endpoints not tested.")
Example #7
0
    def test_post(self):

        test_print("test_setup_post starting")

        # fill in the form and submit with test info
        setup = {
            'userName': '******',
            'userFullName': 'Test User',
            'userEmail': '*****@*****.**',
            'userPassword': '******',
            'userPasswordConfirm': 'test',
            'instanceName': 'Test Synbiohub',
            'instanceURL': 'http://localhost:7777/',
            'uriPrefix': 'http://localhost:7777/',
            'color': '#D25627',
            'frontPageText': 'text',
            'virtuosoINI': '/etc/virtuoso-opensource-7/virtuoso.ini',
            'virtuosoDB': '/var/lib/virtuoso-opensource-7/db',
            'allowPublicSignup': 'true',
        }

        compare_post_request('setup', setup)

        test_print("test_setup_post completed")
Example #8
0
    def test_get_address(self):

        test_print("test_get_address starting")

        # test no parameters
        self.assertEqual(args.serveraddress + "test/url",
                         get_address("test/url", []))
        with self.assertRaises(Exception):
            get_address("test/:green/notparam", ["two", "params"])
        with self.assertRaises(Exception):
            get_address("test/:green/notparam", [])

        self.assertEqual(args.serveraddress + "test/green",
                         get_address("test/:one", ["green"]))

        self.assertEqual(
            args.serveraddress + "test/green/second",
            get_address("test/:one/:gewotri", ["green", "second"]))

        self.assertEqual(
            args.serveraddress + "test/green/second/",
            get_address("test/:one/:gewotri/", ["green", "second"]))

        test_print("test_get_address completed")
Example #9
0
    def test_post_register(self):
        test_print("test_post_register starting")
        data = {
            'username': '******',
            'name': 'ronald',
            'affiliation': 'synbiohubtester',
            'email': '*****@*****.**',
            'password1': 'test1',
            'password2': 'test1'
        }
        compare_post_request("register",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="register1")

        logininfo = {'email': '*****@*****.**', 'password': '******'}
        login_with(logininfo)

        compare_get_request("/profile")

        data = {
            'name': 'ronnie',
            'affiliation': 'notcovid',
            'email': '*****@*****.**',
            'password1': 'test',
            'password2': 'test'
        }
        compare_post_request("profile",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="profile2")

        compare_get_request("/logout")

        test_print("test_post_register completed")

        test_print("test_post_login_token starting")
        logininfo = {'email': '*****@*****.**', 'password': '******'}
        login_with(logininfo)
        test_print("test_post_login_token completed")
Example #10
0
    def test_admin1(self):
        # test_admin_status(self):
        test_print("test_admin_status starting")
        compare_get_request("/admin")
        test_print("test_admin_status completed")

        # test_admin_users(self):
        test_print("test_admin_users starting")
        compare_get_request("/admin/users")
        test_print("test_admin_users completed")

        # test_admin_graphs(self):
        test_print("test_admin_graphs starting")
        compare_get_request("/admin/graphs")
        test_print("test_admin_graphs completed")

        # test_admin_remotes(self):
        test_print("test_admin_remotes starting")
        compare_get_request("/admin/remotes")
        test_print("test_admin_remotes completed")

        # test_admin_theme(self):
        test_print("test_admin_theme starting")
        compare_get_request("/admin/theme")
        test_print("test_admin_theme completed")

        # test_admin_newUser(self):
        test_print("test_admin_newUser GET starting")
        compare_get_request("/admin/newUser")
        test_print("test_admin_newUser GET  completed")

        # test_admin_sparql(self):
        test_print("test_admin_sparql starting")
        compare_get_request("/admin/sparql", headers = {"Accept": "text/html"})
        test_print("test_admin_sparql completed")

        # TODO: fix backup in docker containers
        #def test_admin_backup(self):
        #    compare_get_request("admin/backup")

        #def test_admin_log(self):
        #    compare_get_request("admin/log")

        # test_admin_mail(self):
        test_print("test_admin_mail starting")
        compare_get_request("/admin/mail")
        test_print("test_admin_mail completed")

        # test_post_admin_mail(self):
        test_print("test_post_admin_mail starting")
        data={
            'key': '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',
            'fromEmail' : '*****@*****.**',
        }
        compare_post_request("/admin/mail", data, headers = {"Accept": "text/plain"}, test_name = "admin_mail")
        test_print("test_post_admin_mail completed")

        # test_admin_savePlugin(self):
        test_print("test_admin_savePlugin starting")
        data={
            'id': 'New',
            'category' : 'download',
            'name' : 'test_plugin',
            'url' : 'jimmy',
        }
        compare_post_request("/admin/savePlugin", data, headers = {"Accept": "text/plain"}, test_name = "admin_savePlugin")
        test_print("test_admin_savePlugintatus completed")

        # test_admin_plugins(self):
        test_print("test_admin_plugins starting")
        compare_get_request("/admin/plugins")
        test_print("test_admin_plgins completed")

        # test_admin_saveRegistry(self):
        test_print("test_admin_saveRegistrytatus starting")
        data={
            'uri': 'testurl.com',
            'url' : 'testurl.com',
        }
        compare_post_request("/admin/saveRegistry", data, headers = {"Accept": "text/plain"}, test_name = "admin_saveRegistry")
        test_print("test_admin_saveRegistry completed")

        # test_admin_registries(self):
        test_print("test_admin_registries starting")
        compare_get_request("admin/registries")
        test_print("test_admin_registries completed")

        # TODO: FIGURE OUT ANOTHER WAY TO TEST THIS
        #    def test_admin_retreiveFromWebOfRegistries(self):
        #        data={
        #        }
        #        compare_post_request("/admin/retrieveFromWebOfRegistries", data, headers = {"Accept": "text/plain"}, test_name = "admin_retrieveFromWebOfRegistries")

        #    def test_admin_federate(self):
        #        data={
        #            'administratorEmail': '*****@*****.**',
        #            'webOfRegistries' : 'https://wor.synbiohub.org',
        #        }
        #        compare_post_request("/admin/federate", data, headers = {"Accept": "text/plain"}, test_name = "admin_federate")

        test_print("test_admin_setAdministratorEmail starting")
        data={
            'administratorEmail': '*****@*****.**',
        }
        compare_post_request("/admin/setAdministratorEmail", data, headers = {"Accept": "text/plain"}, test_name = "admin_setAdministratorEmail")
        test_print("test_admin_setAdministratorEmail completed")

        test_print("test_admin_updateTheme starting")
        logo = os.path.basename('./logo.jpg');
        data={
            'instanceName': 'test_instance',
            'frontPageText' : 'test_instance',
            'baseColor' : 'A32423',
            'showModuleInteractions' : 'ok',
        }
        files={
            'logo' : (logo, open('./logo.jpg', 'rb')),
        }
        compare_post_request("/admin/theme", data, headers = {"Accept": "text/plain"}, files = files, test_name = "admin_setAdministratorEmail")
        test_print("test_admin_updateTheme completed")

        test_print("test_admin_status starting")
        data={
            'useSBOLExplorer': 'True',
            'SBOLExplorerEndpoint' : 'http://*****:*****@user.synbiohub',
        #            'affiliation' : 'adminNewUser',
        #            'isMember' : '1',
        #            'isCurator' : '1',
        #            'isAdmin' : '1',
        #        }
        #        compare_post_request("/admin/newUser", data, headers = {"Accept": "text/plain"}, test_name = "admin_newUser")

        #    def test_updateUserConfig(self):
        #        data={
        #            'allowPublicSignup': 'False',
        #        }
        #        compare_post_request("/admin/users", data, headers = {"Accept": "text/plain"}, test_name = "admin_updateUsersConfig")

        # test_updateUser(self):
        test_print("test_updateUser starting")
        data={
            'id': '2',
            'name' : 'ronnieUpdated',
            'email' : '*****@*****.**',
            'affiliation' : 'updatedAffiliation',
            'isMember' : '1',
            'isCurator' : '1',
            'isAdmin' : '1'
        }
        compare_post_request("/admin/updateUser", data, headers = {"Accept": "text/plain"}, test_name = "admin_updateUser")
        test_print("test_updateUser completed")

        test_print("test_admin_newUser GET starting")
        compare_get_request("/admin/newUser", test_name = "test_new_user0")
        test_print("test_admin_newUser GET completed")


        # test_admin_deletePlugin(self):
        test_print("test_admin_deletePlugin starting")
        data={
            'id': '1',
            'category' : 'download',
        }
        compare_post_request("/admin/deletePlugin", data, headers = {"Accept": "text/plain"}, test_name = "admin_deletePlugin")
        test_print("test_admin_deletePlugin completed")

        # test_admin_deleteRegistry(self):
        test_print("test_admin_deleteRegistry starting")
        data={
            'uri': 'testurl.com',
        }
        compare_post_request("/admin/deleteRegistry", data, headers = {"Accept": "text/plain"}, test_name = "admin_deleteRegistry")
        test_print("test_admin_deleteRegistry completed")

        # test_admin_deleteRemoteBenchling(self):
        test_print("test_admin_deleteRemoteBenchling starting")
        data={
            'id': '1',
        }
        compare_post_request("/admin/deleteRemote", data, headers = {"Accept": "text/plain"}, test_name = "admin_deleteRemoteBenchling")
        test_print("test_admin_deleteRemoteBenchling completed")

        # test_admin_deleteRemoteICE(self):
        test_print("test_admin_deleteRemoteICE starting")
        data={
            'id': 'test',
        }
        compare_post_request("/admin/deleteRemote", data, headers = {"Accept": "text/plain"}, test_name = "admin_deleteRemoteICE")
        test_print("test_admin_deleteRemoteICE completed")

        # test_admin_DeleteUser(self):
        test_print("test_admin_DeleteUser starting")
        data={
            'id': '2',
        }
        compare_post_request("/admin/deleteUser", data, headers = {"Accept": "text/plain"}, test_name = "admin_deleteUser")
        test_print("test_admin_DeleteUser completed")

        # test_newUser(self):
        test_print("test_newUser POST starting")
        data = {
            'username': '******',
            'name' : 'adminNewUser',
            'email' : '*****@*****.**',
            'affiliation' : 'adminNewUser',
            'isMember' : '1',
            'isCurator' : '1',
            'isAdmin' : '1',
        }
        compare_post_request("/admin/newUser", data, headers = {"Accept": "text/plain"}, test_name = "admin_newUser1")
        test_print("test_newUser POST completed")
Example #11
0
    def test_collections(TestCase):

        test_print("test_addOwner_get starting")

        #        compare_get_request("/public/:collectionId/:displayId/:version/addOwner", route_parameters = ["testid1","testid1_collection","1"], test_name = "test_get_add_owner_public")
        compare_get_request(
            "user/:userId/:collectionId/:displayId/:version/addOwner",
            route_parameters=[
                "testuser", "testid2", "testid2_collection", "1"
            ],
            test_name="test_get_add_owner_private")

        test_print("test_addOwner_get completed")

        test_print("test_addOwner_post starting")
        data = {
            'uri':
            'http://localhost:7777/user/testuser/testid2/testid2_collection/1',
            'user': '******'
        }
        #        compare_post_request("addOwner", data, headers = {"Accept": "text/plain"},test_name = "test_addOwnerPrivate")

        data = {
            'uri': 'http://localhost:7777/public/testid1/testid1_collection/1',
            'user': '******'
        }
        #        compare_post_request("addOwner", data, headers = {"Accept": "text/plain"},test_name = "test_addOwnerPublic")

        test_print("test_addOwner_post completed")

        test_print("test_addOwner_get starting")

        compare_get_request(
            "user/:userId/:collectionId/:displayId/:version/remove",
            route_parameters=[
                "testuser", "testid2", "testid2_collection", "1"
            ],
            test_name="test_get_add_owner_private")

        test_print("test_addOwner_post completed")

        test_print("test_addOwner_get starting")

        #        compare_get_request("user/:userId/:collectionId/:displayId/:version/replace", route_parameters = ["testuser","testid2","testid2_collection","1"], test_name = "test_get_add_owner_private")

        test_print("test_addOwner_post completed")
Example #12
0
    def test_before_login(self):

        # test_get_main_page(self):
        test_print("test_get_main_page starting")
        compare_get_request("/")
        test_print("test_get_main_page completed")

        # test_get_login(self):
        test_print("test_get_login starting")
        compare_get_request("/login")
        test_print("test_get_login completed")

        # test_post_bad_login(self):
        test_print("test_post_bad_login starting")
        bad_login_info = {'email' : 'bademail',
                          'password' : 'test'}
        compare_post_request("/login", bad_login_info, test_name='bad_admin_login')
        test_print("test_post_bad_login completed")

        # test_no_username_login(self):
        test_print("test_no_username_login starting")
        no_email_info = {'password' : 'test'}
        compare_post_request("/login", no_email_info, test_name='no_email_login')
        test_print("test_no_username_login completed")

        # test_post_login_admin(self):
        test_print("test_post_login_admin starting")
        logininfo = {'email' : '*****@*****.**',
                     'password' : 'test'}
        compare_post_request("/login", logininfo)
        test_print("test_post_login_admin completed")
Example #13
0
    def test_search(self):

        # test_searchQuery(self):
        test_print("test_search starting")
        compare_get_request("/search/:query?", route_parameters=["I0462"])
        test_print("test_search completed")

        # test_searchCount(self):
        test_print("test_searchCount starting")
        compare_get_request("/searchCount/:query?", route_parameters=["I0462"])
        test_print("test_searchCount completed")

        # test_advancedSearch(self):
        test_print("test_advancedSearch GET starting")
        compare_get_request("/advancedSearch")
        test_print("test_advancedSearch completed")

        # test advancedSerach post
        test_print("test_advancedSearch POST starting")
        data = {'description': 'BBa_I0462', 'adv': 'Search'}
        compare_post_request("/advancedSearch", data=data)

        test_print("test_advancedSearch completed")

        # test_rootCollections(self):
        test_print("test_rootCollections starting")
        compare_get_request("/rootCollections")
        test_print("test_rootCollections completed")

        # test_sparql(self):
        test_print("test_sparql starting")
        compare_get_request("/sparql", headers={"Accept": "text/html"})
        test_print("test_sparql completed")

        test_print("test_subcollections_public starting")
        compare_get_request(
            "/public/:collectionId/:displayId/:version/subCollections",
            route_parameters=["testid1", "testid1_collection", "1"],
            headers={"Accept": "text/html"})
        test_print("test_subcollections_public completed")

        # test_uses(self):
        #        test_print("test_uses starting")
        #        compare_get_request("user/:userId/:collectionId/:displayId/:version/uses", route_parameters = ["testuser","testid2", "BBa_B0015", "1"],headers = {"Accept": "text/html"})
        #       test_print("test_uses completed")

        test_print("test_subcollections_private starting")
        compare_get_request(
            "user/:userId/:collectionId/:displayId/:version/subCollections",
            route_parameters=[
                "testuser", "testid2", "testid2_collection", "1"
            ],
            headers={"Accept": "text/html"})
        test_print("test_subcollections_private completed")

        test_print("test_browse_get starting")
        compare_get_request("browse", headers={"Accept": "text/html"})
        test_print("test_browse_get completed")
Example #14
0
    def test_edit(self):
        # test_update_mutableDescription
        test_print("test_update_mutableDescription starting")
        data = {
            'uri': 'http://localhost:7777/public/testid1/testid1_collection/1',
            'value': 'testUpdateMutableDescription'
        }
        compare_post_request("updateMutableDescription",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="test_update_mutableDescription")
        test_print("test_update_mutableDescription completed")

        # test_update_mutableNotes
        test_print("test_update_mutableNotes starting")
        data = {
            'uri': 'http://localhost:7777/public/testid1/testid1_collection/1',
            'value': 'testUpdateMutableNotes'
        }
        compare_post_request("updateMutableNotes",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="test_update_mutableNotes")
        test_print("test_update_mutableNotes completed")

        # test_update_mutableSource
        test_print("test_update_mutableSource starting")
        data = {
            'uri': 'http://localhost:7777/public/testid1/testid1_collection/1',
            'value': 'testUpdateMutableSource'
        }
        compare_post_request("updateMutableSource",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="test_update_mutableSource")
        test_print("test_update_mutableSource completed")

        # test_edit_citations
        test_print("test_edit_citations starting")
        data = {
            'uri': 'http://localhost:7777/public/testid1/testid1_collection/1',
            'value': '1234'
        }
        compare_post_request("updateCitations",
                             data,
                             headers={"Accept": "text/plain"},
                             test_name="test_edit_mutable_citations")
        test_print("test_edit_citations completed")
Example #15
0
    def test_submit(self):
        test_print("test_main_page starting")
        headers = {'Accept': 'text/plain'}
        compare_get_request("/",
                            test_name="after_admin_login",
                            headers=headers)

        test_print("test_main_page completed")

        test_print("test_get_submit_submissions_empty starting")
        compare_get_request("submit")
        compare_get_request("manage")

        # working curl request
        #curl -X POST -H "Accept: text/plain" -H "X-authorization: e35054aa-04e3-425c-afd2-66cb95ff66e1" -F id=green -F version="3" -F name="test" -F description="testd" -F citations="none" -F overwrite_merge="0" -F file=@"./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml" http://localhost:7777/submit"""

        test_print("test_get_submit_submissions_empty completed")

        test_print("test_create_id_missing starting")

        data = {
            'version': (None, '1'),
            'name': (None, 'testcollection'),
            'description': (None, 'testdescription'),
            'citations': (None, 'none'),
            'overwrite_merge': (None, '0')
        }

        files = {
            'file':
            ("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml",
             open(
                 './SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml',
                 'rb'))
        }
        with self.assertRaises(requests.exceptions.HTTPError):
            compare_post_request("submit",
                                 data,
                                 headers={"Accept": "text/plain"},
                                 files=files,
                                 test_name="missing_id")

        test_print("test_create_id_missing completed")

        test_print("test_create_and_delete_collections starting")
        # create the collection
        data = {
            'id': (None, 'testid'),
            'version': (None, '1'),
            'name': (None, 'testcollection'),
            'description': (None, 'testdescription'),
            'citations': (None, 'none'),
            'overwrite_merge': (None, '0')
        }

        files = {
            'file':
            ("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml",
             open(
                 './SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml',
                 'rb'))
        }

        compare_post_request("submit",
                             data,
                             headers={"Accept": "text/plain"},
                             files=files,
                             test_name="submit_test_BBa")
        with self.assertRaises(requests.exceptions.HTTPError):
            compare_post_request("submit",
                                 data,
                                 headers={"Accept": "text/plain"},
                                 files=files,
                                 test_name="submit_already_in_use")

#        self.create_collection2()

        compare_get_request("manage", test_name="two_submissions")
        compare_get_request("submit", test_name="two_submissions")

        # now remove the collections
        compare_get_request(
            '/user/:userId/:collectionId/:displayId/:version/removeCollection',
            route_parameters=["testuser", "testid", "testid_collection", "1"])
        compare_get_request(
            '/user/:userId/:collectionId/:displayId/:version/removeCollection',
            route_parameters=[
                "testuser", "testid2", "testid2_collection", "1"
            ],
            test_name='remove_second')

        compare_get_request("manage", test_name="no_submissions")

        test_print("test_create_and_delete_collections completed")

        test_print("create_collection2 starting")
        data = {
            'id': (None, 'testid2'),
            'version': (None, '1'),
            'name': (None, 'testcollection2'),
            'description': (None, 'testdescription'),
            'citations': (None, 'none'),
            'overwrite_merge': (None, '0')
        }

        files = {
            'file':
            ("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml",
             open(
                 './SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml',
                 'rb'))
        }

        compare_post_request("submit",
                             data,
                             headers={"Accept": "text/plain"},
                             files=files,
                             test_name="create_2")

        # delete collection
        #compare_get_request("/user/testuser/testid2/testid_collection2/1/removeCollection")

        test_print("create_collection2 completed")

        test_print("make_new_collection starting")
        # create the collection
        data = {
            'id': (None, 'testid1'),
            'version': (None, '1'),
            'name': (None, 'testcollection1'),
            'description': (None, 'testdescription1'),
            'citations': (None, 'none'),
            'overwrite_merge': (None, '0')
        }

        files = {
            'file':
            ("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/toggle.xml",
             open(
                 './SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/toggle.xml',
                 'rb'))
        }

        compare_post_request("submit",
                             data,
                             headers={"Accept": "text/plain"},
                             files=files,
                             test_name="generic_collection1")

        test_print("make_new_collection completed")

        #    """ def test_bad_make_public(self):
        #        data = self.make_new_collection("1")
        #
        #        data['tabState'] = 'new'
        #
        #        # try to remove the collection but don't enter a id
        #        del data['id']
        #        with self.assertRaises(requests.exceptions.HTTPError):
        #            compare_post_request("/user/:userId/:collectionId/:displayId/:version/makePublic", route_parameters = ["testuser", "testid1", "testid_collection1", "1"], data = data)
        #    TODO: uncomment when this does raise an HTTPError in synbiohub
        #        """

        test_print("test_make_public starting")

        # get the view
        compare_get_request(
            "/user/:userId/:collectionId/:displayId/:version/makePublic",
            route_parameters=[
                "testuser", "testid0", "testid0_collection", "1"
            ])

        data['tabState'] = 'new'

        # make the collection public
        compare_post_request(
            "/user/:userId/:collectionId/:displayId/:version/makePublic",
            route_parameters=[
                "testuser", "testid1", "testid1_collection", "1"
            ],
            data=data)

        # try to delete the collection
        with self.assertRaises(requests.exceptions.HTTPError):
            compare_get_request(
                "/public/:collectionId/:displayId/:version/removeCollection",
                route_parameters=["testid1", "testid1_collection", "1"],
                test_name='remove')

        test_print("test_make_public completed")
Example #16
0
    def test_attachment(self):
        test_print("test_attachUrl_private starting")
        data={
                'url': 'synbiohub.org',
                'name' : 'synbiohubtestattachurl',
                'type' : 'test',
        }
#        compare_post_request("/user/:userId/:collectionId/:displayId/:version/attachUrl", route_parameters = ["testuser", "testid2", "testid2_collection", "1"], data = data, test_name = "test_attachURL_private")

        test_print("test_attachUrl_private completed")

        test_print("test_attach_private_collection starting")
        files = {'file':("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml", open('./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml', 'rb'))}

        compare_post_request("user/:userId/:collectionId/:displayId/:version/attach",route_parameters = ["testuser", "testid2", "testid2_collection", "1"],data=data,  headers = {"Accept": "text/plain"}, files = files, test_name = "test_attach_to_private_collection2")

        test_print("test_attach_private_collection completed")

        test_print("test_attach_public_collection starting")
        files = {'file':("./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml", open('./SBOLTestRunner/src/main/resources/SBOLTestSuite/SBOL2/BBa_I0462.xml', 'rb'))}

        compare_post_request("public/:collectionId/:displayId/:version/attach",route_parameters = ["testid1", "testid1_collection", "1"],data=data,  headers = {"Accept": "text/plain"}, files = files, test_name = "test_attach_to_public_collection")
        test_print("test_attach_private_collection completed")

#      test_print("test_attachUrl_public starting")
        data={
                'url': 'synbiohub.org',
                'name' : 'synbiohubtestattachurl',
                'type' : 'test',
        }