def test_domain_has_shared_configs(self): config = ReportConfig(domain=self.DOMAIN, owner_id=self.OWNER_ID) config.save() self.addCleanup(config.delete) self._create_scheduled_report( domain=self.DOMAIN, owner_id=self.OWNER_ID, config_ids=[config._id], ) # Clear cached value ReportConfig.shared_on_domain.clear(ReportConfig, domain=self.DOMAIN) configs = list(ReportConfig.shared_on_domain(self.DOMAIN)) self.assertEqual(len(configs), 1) self.assertEqual(configs[0]._id, config._id)
def test_config_used_in_multiple_report_notifications(self): config = ReportConfig(domain=self.DOMAIN, owner_id=self.OWNER_ID) config.save() self.addCleanup(config.delete) self._create_scheduled_report( domain=self.DOMAIN, owner_id=self.OWNER_ID, config_ids=[config._id], ) self._create_scheduled_report( domain=self.DOMAIN, owner_id=self.OWNER_ID, config_ids=[config._id], ) configs = list(ReportConfig.shared_on_domain(self.DOMAIN)) self.assertEqual(len(configs), 1) self.assertEqual(configs[0]._id, config._id)
def test_domain_does_not_have_shared_configs(self): self.assertEqual(len(ReportConfig.shared_on_domain(self.DOMAIN)), 0)