def test_mapping_collection_states_running(self): history_id = self.current_history_id() input_collection = self.dataset_collection_populator.create_list_in_history(history_id, contents=["0", "1"]).json() running_inputs = { "input1": {'batch': True, 'values': [{"src": "hdca", "id": input_collection["id"]}]}, "sleep_time": 60, } running_response = self.dataset_populator.run_tool( "cat_data_and_sleep", running_inputs, history_id, assert_ok=False, ) try: assert_status_code_is(running_response, 200) running_hid = running_response.json()["implicit_collections"][0]["hid"] # sleep really shouldn't be needed :( time.sleep(1) self.home() self.history_panel_wait_for_hid_state(running_hid, "running") self.screenshot("history_panel_collections_state_mapping_running") finally: for job in running_response.json()["jobs"]: self.dataset_populator.cancel_job(job["id"])
def test_create_valid(self): name = self.dataset_populator.get_random_name() description = "A test role." payload = { "name": name, "description": description, "user_ids": json.dumps([self.dataset_populator.user_id()]), } response = self._post("roles", payload, admin=True) assert_status_code_is(response, 200) # TODO: Why does this return a singleton list - that is bad - should be deprecated # and return a single role. role = response.json()[0] RolesApiTestCase.check_role_dict(role) assert role["name"] == name assert role["description"] == description user_roles_response = self._get("roles") with self._different_user(): different_user_roles_response = self._get("roles") user_roles_response_ids = [r["id"] for r in user_roles_response.json()] different_user_roles_response_ids = [r["id"] for r in different_user_roles_response.json()] # This new role is public, all users see it. assert role["id"] in user_roles_response_ids assert role["id"] in different_user_roles_response_ids
def test_output_collection_states_running(self): history_id = self.current_history_id() running_inputs = { "sleep_time": 180, } running_response = self.dataset_populator.run_tool( "collection_creates_dynamic_nested", running_inputs, history_id, assert_ok=False, ) try: assert_status_code_is(running_response, 200) running_hid = running_response.json( )["output_collections"][0]["hid"] # sleep really shouldn't be needed :( time.sleep(1) self.home() self.history_panel_wait_for_hid_state(running_hid, "running") self.screenshot("history_panel_collections_state_running") finally: for job in running_response.json()["jobs"]: self.dataset_populator.cancel_job(job["id"])
def test_mapping_collection_states_running(self): history_id = self.current_history_id() input_collection = self.dataset_collection_populator.create_list_in_history( history_id, contents=["0", "1"]).json() running_inputs = { "input1": { 'batch': True, 'values': [{ "src": "hdca", "id": input_collection["id"] }] }, "sleep_time": 60, } running_response = self.dataset_populator.run_tool( "cat_data_and_sleep", running_inputs, history_id, assert_ok=False, ) try: assert_status_code_is(running_response, 200) running_hid = running_response.json( )["implicit_collections"][0]["hid"] # sleep really shouldn't be needed :( time.sleep(1) self.home() self.history_panel_wait_for_hid_state(running_hid, "running") self.screenshot("history_panel_collections_state_mapping_running") finally: for job in running_response.json()["jobs"]: self.dataset_populator.cancel_job(job["id"])
def test_create_valid(self): name = self.dataset_populator.get_random_name() description = "A test role." payload = { "name": name, "description": description, "user_ids": json.dumps([self.dataset_populator.user_id()]), } response = self._post("roles", payload, admin=True) assert_status_code_is(response, 200) # TODO: Why does this return a singleton list - that is bad - should be deprecated # and return a single role. role = response.json()[0] RolesApiTestCase.check_role_dict(role) assert role["name"] == name assert role["description"] == description user_roles_response = self._get("roles") with self._different_user(): different_user_roles_response = self._get("roles") user_roles_response_ids = [r["id"] for r in user_roles_response.json()] different_user_roles_response_ids = [ r["id"] for r in different_user_roles_response.json() ] # This new role is public, all users see it. assert role["id"] in user_roles_response_ids assert role["id"] in different_user_roles_response_ids
def entry_point_target(self, entry_point_id): entry_point_access_response = self._get("entry_points/%s/access" % entry_point_id) api_asserts.assert_status_code_is(entry_point_access_response, 200) access_json = entry_point_access_response.json() api_asserts.assert_has_key(access_json, "target") return access_json["target"]
def run_tool(self, tool_id, inputs, history_id, assert_ok=True, **kwds): payload = self.run_tool_payload(tool_id, inputs, history_id, **kwds) tool_response = self.tools_post(payload) if assert_ok: api_asserts.assert_status_code_is(tool_response, 200) return tool_response.json() else: return tool_response
def test_show_error_codes(self): # Bad role ids are 400. response = self._get("roles/badroleid") assert_status_code_is(response, 400) # Trying to access roles are errors - should probably be 403 not 400 though? with self._different_user(): different_user_role_id = self.dataset_populator.user_private_role_id() response = self._get("roles/%s" % different_user_role_id) assert_status_code_is(response, 400)
def test_show_error_codes(self): # Bad role ids are 400. response = self._get("roles/badroleid") assert_status_code_is(response, 400) # Trying to access roles are errors - should probably be 403 not 400 though? with self._different_user(): different_user_role_id = self.dataset_populator.user_private_role_id( ) response = self._get("roles/%s" % different_user_role_id) assert_status_code_is(response, 400)
def test_output_collection_states_running(self): history_id = self.current_history_id() running_inputs = { "sleep_time": 180, } running_response = self.dataset_populator.run_tool( "collection_creates_dynamic_nested", running_inputs, history_id, assert_ok=False, ) try: assert_status_code_is(running_response, 200) running_hid = running_response.json()["output_collections"][0]["hid"] # sleep really shouldn't be needed :( time.sleep(1) self.home() self.history_panel_wait_for_hid_state(running_hid, "running") self.screenshot("history_panel_collections_state_running") finally: for job in running_response.json()["jobs"]: self.dataset_populator.cancel_job(job["id"])
def run_tool( self, tool_id, inputs, history_id, **kwds ): payload = self.run_tool_payload( tool_id, inputs, history_id, **kwds ) tool_response = self._post( "tools", data=payload ) api_asserts.assert_status_code_is( tool_response, 200 ) return tool_response.json()
def test_create_only_admin(self): response = self._post("roles") assert_status_code_is(response, 403)
def entry_points_for_job(self, job_id): entry_points_response = self._get("entry_points?job_id=%s" % job_id) api_asserts.assert_status_code_is(entry_points_response, 200) return entry_points_response.json()