def test_click_dynamic_link(self) -> None: dyn_link = find_component_by_attribute_in_dict( "label", "Settings", json.loads(self.form_content_2)) self.custom_locust.set_response("", 200, "{}") output = self.task_set.appian.interactor.click_link( "", dyn_link, {}, "") self.assertEqual(output, dict())
def test_fill_textfield(self) -> None: text_title = find_component_by_attribute_in_dict( "label", "Title", json.loads(self.form_content)) self.custom_locust.set_response("", 200, "{}") output = self.task_set.appian.interactor.fill_textfield( "", text_title, "something", {}, "", "") self.assertEqual(output, dict())
def test_click_nested_dynamic_link(self) -> None: dyn_link = find_component_by_attribute_in_dict( "label", "I need to update my Account details", json.loads(self.nested_dynamic_link_json)) self.custom_locust.set_response("", 200, "{}") output = self.task_set.appian.interactor.click_link( "", dyn_link, {}, "") self.assertEqual(output, dict())
def test_find_component_by_attribute_in_dict(self) -> None: dir_path = os.path.dirname(os.path.realpath(__file__)) raw_data = read_mock_file("library_utils.json") testdata = json.loads(raw_data) output = helper.find_component_by_attribute_in_dict( 'step2_status', 'pass', testdata) self.assertTrue(output["step2_status"] == "pass")
def test_click_record_link(self) -> None: record_link = find_component_by_attribute_in_dict( "label", "Profile", json.loads(self.form_content_2)) self.custom_locust.set_response( "/suite/sites/record/nkB0AwAXQzsQm2O6Of7dMdydaKrNT9uUisGhgFHLyZXpnCB2kjcXoiFJRK5SlL5Bt_GvQEcqlclEadcUWUJ9fCR6GnV1GcZA0cQDe2zoojxnd4W1rs06fDnxgqf" + "-Pa9TcPwsNOpNrv_mvgEFfGrsSLB4BALxCD8JZ--/view/summary", 200, "{}") output = self.task_set.appian.interactor.click_record_link( "/suite/sites/record/some_long_record_id/view/summary", record_link, {}, "") self.assertEqual(output, dict())
def test_record_action_refresh_builder(self) -> None: # Test the interaction with _save_builder used by _interactor.refresh_after_record_action record_action_component = find_component_by_attribute_in_dict("label", "Update Table 1 (Dup) (PSF)", json.loads( self.record_action_launch_form_before_refresh )) record_action_trigger_component = find_component_by_attribute_in_dict( "_actionName", "sail:record-action-trigger", json.loads( self.record_action_launch_form_before_refresh )) context = find_component_by_attribute_in_dict("type", "stateful", json.loads( self.record_action_launch_form_before_refresh )) uuid = "345f89d4-b2b4-4c8c-a2a3-2b578e6292df" # Get the payload for the record action on submit record_action_payload = save_builder() \ .component(record_action_component) \ .context(context) \ .uuid(uuid) \ .value(dict()) \ .build() # Get the payload for the record action trigger record_action_trigger_payload = save_builder() \ .component(record_action_trigger_component) \ .context(context) \ .uuid(uuid) \ .value(dict()) \ .build() self.assertEqual(record_action_payload, json.loads(self.record_action_component_payload_json)) self.assertEqual(record_action_trigger_payload, json.loads(self.record_action_trigger_payload_json))
def test_record_link_tempo_report(self) -> None: record_link = find_component_by_attribute_in_dict( "label", "DA0G-P2A6", json.loads(self.form_content_3)) mock = unittest.mock.Mock() setattr(self.task_set.appian.interactor, 'get_page', mock) self.task_set.appian.interactor.click_record_link( "/suite/tempo/reports/view/oxy4ed", record_link, {}, "") mock.assert_called_once() # Assert get_page() called with first argument as the correct record link url recordRef = record_link.get("_recordRef") expected_record_link_url = f"('/suite/tempo/records/item/{recordRef}/view/summary',)" self.assertEqual(f"{mock.call_args[0]}", expected_record_link_url)
def test_record_link_sites_record(self) -> None: record_link = find_component_by_attribute_in_dict( "label", "Profile", json.loads(self.form_content_2)) mock = unittest.mock.Mock() setattr(self.task_set.appian.interactor, 'get_page', mock) self.task_set.appian.interactor.click_record_link( "/suite/sites/records/page/db/record/some-record-ref/view/summary", record_link, {}, "") mock.assert_called_once() # Assert get_page() called with first argument as the correct record link url recordRef = record_link.get("_recordRef") expected_record_link_url = f"('/suite/sites/records/page/db/record/{recordRef}/view/summary',)" self.assertEqual(f"{mock.call_args[0]}", expected_record_link_url)
def test_click_related_action_on_record_form(self) -> None: self.custom_locust.set_response('/suite/rest/a/record/latest/BE5pSw/ioBHer_bdD8Emw8hMSiA_CnpxaK0CVK61sPetEqM0lI_pHvjAsXVOlJtUo/actions/' 'ioBHer_bdD8Emw8hMSiA_CnpxaA0SVKp1kzE9BURlYvkxHjzPlX0d81Hmk', 200, self.related_action_response) sail_form = SailUiForm(self.task_set.appian.interactor, json.loads(self.record_instance_response), '/suite/rest/a/sites/latest/D6JMim/page/records/record/' 'lIBHer_bdD8Emw8hLPETeiApJ24AA5ZJilzpBmewf--PdHDSUx022ZVdk6bhtcs5w_3twr_z1drDBwn8DKfhPp90o_A4GrZbDSh09DYkh5Mfq48' '/view/summary') record_instance_header_form = sail_form.get_record_header_form() # perform a related action record_instance_related_action_form = record_instance_header_form.click_related_action("Discuss Case History") # Assert fields on the related action form text_component = find_component_by_attribute_in_dict('label', 'Action Type', record_instance_related_action_form.state) self.assertEqual(text_component.get("#t"), "TextField")
def test_deployments_click_tab(self) -> None: design_landing_page_response = read_mock_file("design_landing_page.json") deployment_tab_response = read_mock_file("design_deployments_ui.json") deployment_outgoing_tab_response = read_mock_file("design_deployments_outgoing_tab.json") self.custom_locust.set_response(self.design_uri, 200, design_landing_page_response) design_sail_form = self.task_set.appian.design.visit() self.custom_locust.set_response(self.design_uri, 200, deployment_tab_response) deployments_sail_form = design_sail_form.click("Deployments") self.custom_locust.set_response("/suite/rest/a/applications/latest/app/design/deployments", 200, deployment_outgoing_tab_response) outgoing_tab_form = deployments_sail_form.get_latest_form().click_tab_by_label("Outgoing", "deployment-secondary-tabs") component = find_component_by_attribute_in_dict("label", "OneApp", outgoing_tab_form.latest_state) self.assertEqual("OneApp", component.get('label'))
def start_process_link_test_helper(self, is_mobile: bool = False) -> None: spl_component = find_component_by_attribute_in_dict( "label", "Check In", json.loads(self.response_with_start_process_link)) mock = unittest.mock.Mock() process_model_opaque_id = spl_component.get("processModelOpaqueId") cache_key = spl_component.get("cacheKey") site_name = "covid-19-response-management" page_name = "home" setattr(self.task_set.appian.interactor, 'post_page', mock) self.task_set.appian.interactor.click_start_process_link( spl_component, process_model_opaque_id, cache_key, site_name, page_name, is_mobile) mock.assert_called_once() if not is_mobile: expected_spl_link_url = f"('/suite/rest/a/sites/latest/{site_name}/page/{page_name}/startProcess/{process_model_opaque_id}?cacheKey={cache_key}',)" else: expected_spl_link_url = f"('/suite/rest/a/model/latest/startProcess/{process_model_opaque_id}?cacheKey={cache_key}',)" self.assertEqual(f"{mock.call_args[0]}", expected_spl_link_url)
def test_dispatch_click_task_with_id(self) -> None: uri = self.report_link_uri sites_task_report = SailUiForm(self.task_set.appian.interactor, json.loads(self.sites_task_report_resp), uri) initial_uuid = sites_task_report.uuid initial_context = sites_task_report.context task_to_accept = read_mock_file('task_accept_resp.json') self.custom_locust.set_response( "/suite/rest/a/task/latest/Bs3k2OfS55jCOcMb5D/status", 200, task_to_accept ) self.custom_locust.set_response( "/suite/rest/a/task/latest/Bs3k2OfS55jCOcMb5D/attributes", 200, """{ "isOfflineTask": false, "isSailTask": true, "isQuickTask": false, "taskId": "Bs3k2OfS55jCOcMb5D", "isAutoAcceptable": "true" }""") sites_task_report.click('Issue recommendation') task_to_accept_state = json.loads(task_to_accept) self.assertNotEqual(initial_uuid, sites_task_report.uuid) self.assertNotEqual(initial_context, sites_task_report.context) self.assertEqual(task_to_accept_state['uuid'], sites_task_report.uuid) self.assertEqual(task_to_accept_state['context'], sites_task_report.context) # Assert ui state updated self.assertEqual('Available Case Workers', find_component_by_attribute_in_dict('label', 'Available Case Workers', sites_task_report.state).get('label') )
def test_find_component_by_attribute_in_dict(self) -> None: component = find_component_by_attribute_in_dict( 'label', 'Request Pass', self.form_dict) # finds first component by that label self.assertEqual(component['#t'], 'RichTextDisplayField')
def test_click_record_link_error_fake_uri(self) -> None: record_link = find_component_by_attribute_in_dict( "label", "Profile", json.loads(self.form_content_2)) with self.assertRaises(Exception): self.task_set.appian.interactor.click_record_link( "fake_uri", record_link, {}, "")