def test_fixtures_in_graph(self, *args): expected_suite = parse_normalize( self.get_xml('suite-fixture-graphing'), to_string=False) actual_suite = parse_normalize(Application.wrap( self.get_json('app_fixture_graphing')).create_suite(), to_string=False) expected_configuration_list = expected_suite.findall( 'detail/field/template/graph/configuration') actual_configuration_list = actual_suite.findall( 'detail/field/template/graph/configuration') self.assertEqual(len(expected_configuration_list), 1) self.assertEqual(len(actual_configuration_list), 1) expected_configuration = expected_configuration_list[0] actual_configuration = actual_configuration_list[0] self.assertItemsEqual([ tostring(text_element) for text_element in expected_configuration ], [tostring(text_element) for text_element in actual_configuration]) expected_suite.find('detail/field/template/graph').remove( expected_configuration) actual_suite.find('detail/field/template/graph').remove( actual_configuration) self.assertXmlEqual(tostring(expected_suite), tostring(actual_suite))
def test_default_search(self, *args): suite = self.app.create_suite() suite = parse_normalize(suite, to_string=False) self.assertEqual("false", suite.xpath("./remote-request[1]/session/query/@default_search")[0]) self.module.search_config.default_search = True suite = self.app.create_suite() suite = parse_normalize(suite, to_string=False) self.assertEqual("true", suite.xpath("./remote-request[1]/session/query/@default_search")[0])
def _assertMediaSuiteResourcesEqual(self, expectedXml, actualXml): parsedExpected = parse_normalize(expectedXml, to_string=False) expectedResources = { node.text for node in parsedExpected.findall("media/resource/location") } parsedActual = parse_normalize(actualXml, to_string=False) actualResources = { node.text for node in parsedActual.findall("media/resource/location") } self.assertSetEqual(expectedResources, actualResources)
def test_case_search_action_relevant_condition(self, *args): condition = "'foo' = 'bar'" self.module.search_config.search_button_display_condition = condition suite = self.app.create_suite() suite = parse_normalize(suite, to_string=False) self.assertEqual(condition, suite.xpath('./detail[1]/action/@relevant')[0])
def test_additional_types(self, *args): another_case_type = "another_case_type" self.module.search_config.additional_case_types = [another_case_type] suite_xml = self.app.create_suite() suite = parse_normalize(suite_xml, to_string=False) ref_path = './remote-request[1]/session/datum/@nodeset' self.assertEqual( "instance('{}')/{}/case[@case_type='{}' or @case_type='{}'][{}]{}".format( RESULTS_INSTANCE, RESULTS_INSTANCE, self.module.case_type, another_case_type, self.module.search_config.search_filter, EXCLUDE_RELATED_CASES_FILTER ), suite.xpath(ref_path)[0] ) self.assertXmlPartialEqual( """ <partial> <data key="case_type" ref="'case'"/> <data key="case_type" ref="'another_case_type'"/> </partial> """, suite_xml, "./remote-request[1]/session/query/data[@key='case_type']" )
def test_case_search_filter(self, *args): search_filter = "rating > 3" self.module.search_config.search_filter = search_filter suite = self.app.create_suite() suite = parse_normalize(suite, to_string=False) ref_path = './remote-request[1]/session/datum/@nodeset' self.assertEqual( "instance('{}')/{}/case[@case_type='{}'][{}]".format( RESULTS_INSTANCE, RESULTS_INSTANCE, self.module.case_type, search_filter), suite.xpath(ref_path)[0])
def test_additional_types__shadow_module(self, *args): shadow_module = self.app.add_module(ShadowModule.new_module("shadow", "en")) shadow_module.source_module_id = self.module.get_or_create_unique_id() shadow_module.search_config = CaseSearch( search_label=CaseSearchLabel( label={ 'en': 'Search from Shadow Module' } ), properties=[ CaseSearchProperty(name='name', label={'en': 'Name'}), ], ) another_case_type = "another_case_type" self.module.search_config.additional_case_types = [another_case_type] app = Application.wrap(self.app.to_json()) suite_xml = app.create_suite() suite = parse_normalize(suite_xml, to_string=False) ref_path = './remote-request[2]/session/datum/@nodeset' self.assertEqual( "instance('{}')/{}/case[@case_type='{}' or @case_type='{}']{}".format( RESULTS_INSTANCE, RESULTS_INSTANCE, self.module.case_type, another_case_type, EXCLUDE_RELATED_CASES_FILTER ), suite.xpath(ref_path)[0] ) self.assertXmlPartialEqual( """ <partial> <data key="case_type" ref="'case'"/> <data key="case_type" ref="'another_case_type'"/> </partial> """, suite_xml, "./remote-request[2]/session/query/data[@key='case_type']" )
def test_case_search_action_relevant_condition(self): condition = "'foo' = 'bar'" self.module.search_config.search_button_display_condition = condition suite = self.app.create_suite() suite = parse_normalize(suite, to_string=False) self.assertEqual(condition, suite.xpath('./detail[1]/action/@relevant')[0])
def _assertMediaSuiteResourcesEqual(self, expectedXml, actualXml): parsedExpected = parse_normalize(expectedXml, to_string=False) expectedResources = {node.text for node in parsedExpected.findall("media/resource/location")} parsedActual = parse_normalize(actualXml, to_string=False) actualResources = {node.text for node in parsedActual.findall("media/resource/location")} self.assertSetEqual(expectedResources, actualResources)