def test_updating_report_that_shares_data_source(self): """ If a report builder builder report shares a data source with another report, then editing the report builder report should result in a new data source being created for the report. """ # Make report builder_form = ConfigureListReportForm( self.domain, "Test Report", self.app._id, "form", self.form.unique_id, existing_report=None, data={ 'user_filters': '[]', 'default_filters': '[]', 'columns': '[{"property": "/data/first_name", "display_text": "first name", "calculation":"Group By"}]', }) self.assertTrue(builder_form.is_valid()) report = builder_form.create_report() # Make another report that references the same data source report_two = ReportConfiguration(domain="domain", config_id=report.config_id) report_two.save() # Make an edit to the first report builder report builder_form = ConfigureListReportForm( self.domain, "Test Report", self.app._id, "form", self.form.unique_id, existing_report=report, data={ 'user_filters': '[]', 'default_filters': '[]', 'columns': '[{"property": "/data/first_name", "display_text": "first name", "calculation": "Group By"}]', }) self.assertTrue(builder_form.is_valid()) report = builder_form.update_report() self.assertNotEqual(report.config_id, report_two.config_id)
def test_updating_report_that_shares_data_source(self): """ If a report builder builder report shares a data source with another report, then editing the report builder report should result in a new data source being created for the report. """ # Make report builder_form = ConfigureListReportForm( "Test Report", self.app._id, "form", self.form.unique_id, existing_report=None, data={ 'user_filters': '[]', 'default_filters': '[]', 'columns': '[{"property": "/data/first_name", "display_text": "first name"}]', } ) self.assertTrue(builder_form.is_valid()) report = builder_form.create_report() # Make another report that references the same data source report_two = ReportConfiguration( domain="domain", config_id=report.config_id ) report_two.save() # Make an edit to the first report builder report builder_form = ConfigureListReportForm( "Test Report", self.app._id, "form", self.form.unique_id, existing_report=report, data={ 'user_filters': '[]', 'default_filters': '[]', 'columns': '[{"property": "/data/first_name", "display_text": "first name"}]', } ) self.assertTrue(builder_form.is_valid()) report = builder_form.update_report() self.assertNotEqual(report.config_id, report_two.config_id)
def test_updating_out_of_date_report(self): """ Test that editing a report for an outdated data source creates a new data source. Data sources are tied to app version. """ # Make report builder_form = ConfigureListReportForm( "Test Report", self.app._id, "form", self.form.unique_id, existing_report=None, data={ 'filters': '[]', 'columns': '[]', } ) self.assertTrue(builder_form.is_valid()) report = builder_form.create_report() first_data_source_id = report.config_id # Bump version of app by saving it self.app.save() # Modify the report builder_form = ConfigureListReportForm( "Test Report", self.app._id, "form", self.form.unique_id, existing_report=report, data={ 'filters': '[]', 'columns': '[]' } ) self.assertTrue(builder_form.is_valid()) report = builder_form.update_report() second_data_source_id = report.config_id self.assertNotEqual(first_data_source_id, second_data_source_id)
def test_updating_out_of_date_report(self): """ Test that editing a report for an outdated data source creates a new data source. Data sources are tied to app version. """ # Make report builder_form = ConfigureListReportForm("Test Report", self.app._id, "form", self.form.unique_id, existing_report=None, data={ 'filters': '[]', 'columns': '[]', }) self.assertTrue(builder_form.is_valid()) report = builder_form.create_report() first_data_source_id = report.config_id # Bump version of app by saving it self.app.save() # Modify the report builder_form = ConfigureListReportForm("Test Report", self.app._id, "form", self.form.unique_id, existing_report=report, data={ 'filters': '[]', 'columns': '[]' }) self.assertTrue(builder_form.is_valid()) report = builder_form.update_report() second_data_source_id = report.config_id self.assertNotEqual(first_data_source_id, second_data_source_id)