def setUpClass(cls): delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_uuid = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' cls.user = create_restore_user( domain=cls.domain, username='******', ) update_toggle_cache(MOBILE_UCR.slug, cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) cls.report_configs_by_id = {cls.report_id: report_configuration} cls.app = Application.new_app(cls.domain, "Report Filter Test App", APP_V2) module = cls.app.add_module( ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", graph_configs={ '7451243209119342931': ReportGraphConfig(series_configs={'count': {}}) }, filters={ 'computed_owner_name_40cc88a0_1': MobileSelectFilter() }, uuid=cls.report_config_uuid, )) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ { 'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory' }, { 'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims' }, { 'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel' }, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch( 'corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): fixture, = report_fixture_generator(cls.user, '2.0') cls.fixture = ElementTree.tostring(fixture)
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_uuid = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' cls.user = create_restore_user( domain=cls.domain, username='******', ) update_toggle_cache(MOBILE_UCR.slug, cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) cls.report_configs_by_id = { cls.report_id: report_configuration } cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module(ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", )], ) }, filters={ 'computed_owner_name_40cc88a0_1': MobileSelectFilter(), 'fav_fruit_abc123_1': MobileSelectFilter() }, uuid=cls.report_config_uuid, ) ) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ {'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c'}, {'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b'}, {'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b'}, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch('corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_sql_backend(): with mock_datasource_config(): fixture, = call_fixture_generator(report_fixture_generator, cls.user) cls.fixture = ElementTree.tostring(fixture)
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_uuid = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) cls.report_configs_by_id = { cls.report_id: report_configuration } cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module(ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", )], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_uuid, ) ) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ {'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c'}, {'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b'}, {'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b'}, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch('corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixture, = call_fixture_generator(report_fixture_generator, cls.user) cls.fixture = ElementTree.tostring(fixture)
def setUpClass(cls): delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_uuid = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' cls.user = create_restore_user( domain=cls.domain, username='******', ) update_toggle_cache(MOBILE_UCR.slug, cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) cls.report_configs_by_id = { cls.report_id: report_configuration } cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module(ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", graph_configs={ '7451243209119342931': ReportGraphConfig( series_configs={'count': {}} ) }, filters={'computed_owner_name_40cc88a0_1': MobileSelectFilter()}, uuid=cls.report_config_uuid, ) ) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ {'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory'}, {'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims'}, {'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel'}, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch('corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_sql_backend(): with mock_datasource_config(): fixture, = report_fixture_generator(cls.user, '2.0') cls.fixture = ElementTree.tostring(fixture)
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_mobile_id = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' create_domain(cls.domain) cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) ADD_ROW_INDEX_TO_MOBILE_UCRS.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) # also make a report with a hidden column cls.hidden_column_report_id = 'bd2a43018ad9463682165c1bc16347ac' cls.hidden_column_mobile_id = '45152061d8dc4d2a8d987a0568abe1ae' report_configuration_with_hidden_column = MAKE_REPORT_CONFIG( cls.domain, cls.hidden_column_report_id, columns=[ FieldColumn( type='field', aggregation="simple", column_id="color_94ec39e6", display="color", field="color_94ec39e6" ).to_json(), FieldColumn( type='field', aggregation="simple", column_id="hidden_color_94ec39e6", display="color", field="color_94ec39e6", visible=False, ).to_json(), ] ) cls.report_configs_by_id = { cls.report_id: report_configuration, cls.hidden_column_report_id: report_configuration_with_hidden_column } cls.app = Application.new_app(cls.domain, "Report Filter Test App") report_module = cls.app.add_module(ReportModule.new_module("Report Module", 'en')) report_module.report_context_tile = True report_module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", )], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_mobile_id, ) ) report_module.report_configs.append( ReportAppConfig( report_id=cls.hidden_column_report_id, header={}, description="", complete_graph_configs={}, filters={}, uuid=cls.hidden_column_mobile_id, ) ) case_module = cls.app.add_module(Module.new_module("Case Module", 'en')) case_module.case_type = "fish" case_module.report_context_tile = True case_form = case_module.new_form("Update Fish", None) case_form.requires = "case" case_form.xmlns = "http://openrosa.org/formdesigner/2423EFB5-2E8C-4B8F-9DA0-23FFFD4391AF" survey_module = cls.app.add_module(Module.new_module("Survey Module", 'en')) survey_module.report_context_tile = True survey_form = survey_module.new_form("Survey", None) survey_form.xmlns = "http://openrosa.org/formdesigner/2423EFB5-2E8C-4B8F-9DA0-23FFFD4391AE" with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ {'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c'}, {'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b'}, {'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b'}, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch('corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixtures = call_fixture_generator(report_fixture_generator, cls.user) fixture = [f for f in fixtures if f.attrib.get('id') == ReportFixturesProviderV1.id][0] cls.fixture = ElementTree.tostring(fixture, encoding='utf-8')
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_mobile_id = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' create_domain(cls.domain) cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) # also make a report with a hidden column cls.hidden_column_report_id = 'bd2a43018ad9463682165c1bc16347ac' cls.hidden_column_mobile_id = '45152061d8dc4d2a8d987a0568abe1ae' report_configuration_with_hidden_column = MAKE_REPORT_CONFIG( cls.domain, cls.hidden_column_report_id, columns=[ FieldColumn( type='field', aggregation="simple", column_id="color_94ec39e6", display="color", field="color_94ec39e6" ).to_json(), FieldColumn( type='field', aggregation="simple", column_id="hidden_color_94ec39e6", display="color", field="color_94ec39e6", visible=False, ).to_json(), ] ) cls.report_configs_by_id = { cls.report_id: report_configuration, cls.hidden_column_report_id: report_configuration_with_hidden_column } cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module(ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", )], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_mobile_id, ) ) module.report_configs.append( ReportAppConfig( report_id=cls.hidden_column_report_id, header={}, description="", complete_graph_configs={}, filters={}, uuid=cls.hidden_column_mobile_id, ) ) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ {'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c'}, {'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b'}, {'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b'}, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch('corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixture, = call_fixture_generator(report_fixture_generator, cls.user) cls.fixture = ElementTree.tostring(fixture)
def setUpClass(cls): super(ReportFiltersSuiteTest, cls).setUpClass() delete_all_users() cls.report_id = '7b97e8b53d00d43ca126b10093215a9d' cls.report_config_mobile_id = 'a98c812873986df34fd1b4ceb45e6164ae9cc664' cls.domain = 'report-filter-test-domain' create_domain(cls.domain) cls.user = create_restore_user( domain=cls.domain, username='******', ) MOBILE_UCR.set(cls.domain, True, NAMESPACE_DOMAIN) report_configuration = cls.make_report_config(cls.domain, cls.report_id) # also make a report with a hidden column cls.hidden_column_report_id = 'bd2a43018ad9463682165c1bc16347ac' cls.hidden_column_mobile_id = '45152061d8dc4d2a8d987a0568abe1ae' report_configuration_with_hidden_column = MAKE_REPORT_CONFIG( cls.domain, cls.hidden_column_report_id, columns=[ FieldColumn(type='field', aggregation="simple", column_id="color_94ec39e6", display="color", field="color_94ec39e6").to_json(), FieldColumn( type='field', aggregation="simple", column_id="hidden_color_94ec39e6", display="color", field="color_94ec39e6", visible=False, ).to_json(), ]) cls.report_configs_by_id = { cls.report_id: report_configuration, cls.hidden_column_report_id: report_configuration_with_hidden_column } cls.app = Application.new_app(cls.domain, "Report Filter Test App") module = cls.app.add_module( ReportModule.new_module("Report Module", 'en')) module.report_configs.append( ReportAppConfig( report_id=cls.report_id, header={}, description="", complete_graph_configs={ '7451243209119342931': GraphConfiguration( graph_type="bar", series=[ GraphSeries( config={}, locale_specific_config={}, data_path="", x_function="", y_function="", ) ], ) }, filters=OrderedDict([ ('fav_fruit_abc123_1', MobileSelectFilter()), ('computed_owner_name_40cc88a0_1', MobileSelectFilter()), ]), uuid=cls.report_config_mobile_id, )) module.report_configs.append( ReportAppConfig( report_id=cls.hidden_column_report_id, header={}, description="", complete_graph_configs={}, filters={}, uuid=cls.hidden_column_mobile_id, )) with mock_report_configurations(cls.report_configs_by_id): cls.suite = cls.app.create_suite() cls.data = [ { 'color_94ec39e6': 'red', 'count': 2, 'computed_owner_name_40cc88a0': 'cory', 'fav_fruit_abc123': 'c' }, { 'color_94ec39e6': 'black', 'count': 1, 'computed_owner_name_40cc88a0': 'ctsims', 'fav_fruit_abc123': 'b' }, { 'color_94ec39e6': 'red', 'count': 3, 'computed_owner_name_40cc88a0': 'daniel', 'fav_fruit_abc123': 'b' }, ] with mock_report_data(cls.data): with mock_report_configuration_get(cls.report_configs_by_id): with mock.patch( 'corehq.apps.app_manager.fixtures.mobile_ucr.get_apps_in_domain', lambda domain, include_remote: [cls.app]): with mock_datasource_config(): fixture, = call_fixture_generator( report_fixture_generator, cls.user) cls.fixture = ElementTree.tostring(fixture)