def get_report_fixture_for_user(domain, report_id, ota_user): """ :param domain: the domain :param report_id: the index to the result from get_report_configs() :param ota_user: the OTARestoreCommCareUser for which to get the report fixture """ return ReportFixturesProvider.report_config_to_fixture( get_report_configs(domain)[report_id], ota_user)
def test_v1_report_fixtures_provider(self): report_id = 'deadbeef' provider = ReportFixturesProvider() report_app_config = ReportAppConfig( uuid='c0ffee', report_id=report_id, filters={'computed_owner_name_40cc88a0_1': StaticChoiceListFilter()} ) user = Mock() with mock_report_configuration_get({report_id: MAKE_REPORT_CONFIG('test_domain', report_id)}), \ patch('corehq.apps.app_manager.fixtures.mobile_ucr.ConfigurableReportDataSource') as report_datasource: report_datasource.from_spec.return_value = self.get_data_source_mock() report = provider.report_config_to_v1_fixture(report_app_config, user) self.assertEqual( etree.tostring(report, pretty_print=True), self.get_xml('expected_report') )
def test_report_fixtures_provider(self): report_id = 'deadbeef' provider = ReportFixturesProvider() report_app_config = ReportAppConfig( uuid='c0ffee', report_id=report_id, filters={'computed_owner_name_40cc88a0_1': StaticChoiceListFilter()} ) user = Mock() with mock_report_configuration_get({report_id: MAKE_REPORT_CONFIG('test_domain', report_id)}), \ patch('corehq.apps.app_manager.fixtures.mobile_ucr.ReportFactory') as report_factory_patch: report_factory_patch.from_spec.return_value = self.get_data_source_mock() report = provider.report_config_to_fixture(report_app_config, user) self.assertEqual( etree.tostring(report, pretty_print=True), self.get_xml('expected_report') )
def _get_report_fixture_for_user(domain, report_id, ota_user): """ :param domain: the domain :param report_id: the index to the result from get_report_configs() :param ota_user: the OTARestoreCommCareUser for which to get the report fixture """ xml = ReportFixturesProvider.report_config_to_v1_fixture( get_report_configs(domain)[report_id], ota_user ) return etree.tostring(xml)
def get_report_fixture(self, report_id): return ReportFixturesProvider.report_config_to_fixture( self.report_configs[report_id], self.restore_user)