def tearDown(self): for user in self.users: django_user = user.get_django_user() django_user.delete() user.delete() delete_all_cases() clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, TEST_DOMAIN, toggles.NAMESPACE_DOMAIN)
def tearDownClass(cls): for user in cls.users: django_user = user.get_django_user() django_user.delete() user.delete() clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, TEST_DOMAIN, toggles.NAMESPACE_DOMAIN) super(CaseAPITest, cls).tearDownClass()
def setUp(self): self.project = Domain(name=self.domain) self.project.save() clear_toggle_cache(NEW_EXPORTS.slug, self.domain, namespace=NAMESPACE_DOMAIN) set_toggle(NEW_EXPORTS.slug, self.domain, False, namespace=NAMESPACE_DOMAIN)
def post(self, request, *args, **kwargs): toggle = self.get_toggle() item_list = request.POST.get('item_list', []) if item_list: item_list = json.loads(item_list) item_list = [u for u in item_list if u] affected_users = set(toggle.enabled_users) | set(item_list) toggle.enabled_users = item_list toggle.save() for item in affected_users: clear_toggle_cache(toggle.slug, item) data = {'item_list': item_list} return HttpResponse(json.dumps(data), mimetype="application/json")
def tearDown(self): self.contact.delete() self.backend.delete() self.backend_mapping.delete() delete_domain_phone_numbers(self.domain) SmsBillable.objects.filter(domain=self.domain).delete() QueuedSMS.objects.all().delete() SMS.objects.filter(domain=self.domain).delete() self.domain_obj.delete() clear_toggle_cache(RETRY_SMS_INDEFINITELY.slug, self.domain, NAMESPACE_DOMAIN) super(QueueingTestCase, self).tearDown()
def _call_save_fn_and_clear_cache(toggle_slug, changed_entries, currently_enabled, static_toggle): for entry in changed_entries: enabled = entry in currently_enabled namespace, entry = parse_toggle(entry) if namespace == NAMESPACE_DOMAIN: domain = entry if static_toggle.save_fn is not None: static_toggle.save_fn(domain, enabled) toggle_js_domain_cachebuster.clear(domain) else: # these are sent down with no namespace assert ':' not in entry, entry username = entry toggle_js_user_cachebuster.clear(username) clear_toggle_cache(toggle_slug, entry, namespace=namespace)
def post(self, request, *args, **kwargs): toggle = self.get_toggle() item_list = request.POST.get('item_list', []) if item_list: item_list = json.loads(item_list) item_list = [u.strip() for u in item_list if u and u.strip()] affected_users = set(toggle.enabled_users) | set(item_list) toggle.enabled_users = item_list toggle.save() for item in affected_users: clear_toggle_cache(toggle.slug, item) data = { 'item_list': item_list } return HttpResponse(json.dumps(data), mimetype="application/json")
def post(self, request, *args, **kwargs): toggle = self.get_toggle() item_list = request.POST.get('item_list', []) if item_list: item_list = json.loads(item_list) item_list = [u.strip() for u in item_list if u and u.strip()] previously_enabled = set(toggle.enabled_users) currently_enabled = set(item_list) toggle.enabled_users = item_list toggle.save() changed_entries = previously_enabled ^ currently_enabled # ^ means XOR self.call_save_fn(changed_entries, currently_enabled) for item in changed_entries: clear_toggle_cache(toggle.slug, item) data = {'item_list': item_list} return HttpResponse(json.dumps(data), content_type="application/json")
def test_toggle_cache(self): ns = 'ns' toggle = Toggle(slug=self.slug, enabled_users=['mojer', namespaced_item('fizbod', ns)]) toggle.save() self.assertTrue(toggle_enabled(self.slug, 'mojer')) self.assertFalse(toggle_enabled(self.slug, 'fizbod')) self.assertTrue(toggle_enabled(self.slug, 'fizbod', namespace=ns)) update_toggle_cache(self.slug, 'mojer', False) update_toggle_cache(self.slug, 'fizbod', False, namespace=ns) self.assertFalse(toggle_enabled(self.slug, 'mojer')) self.assertFalse(toggle_enabled(self.slug, 'fizbod', namespace=ns)) clear_toggle_cache(self.slug, 'mojer') clear_toggle_cache(self.slug, 'fizbod', namespace=ns) self.assertTrue(toggle_enabled(self.slug, 'mojer')) self.assertTrue(toggle_enabled(self.slug, 'fizbod', namespace=ns))
def post(self, request, *args, **kwargs): toggle = self.get_toggle() item_list = request.POST.get('item_list', []) if item_list: item_list = json.loads(item_list) item_list = [u.strip() for u in item_list if u and u.strip()] previously_enabled = set(toggle.enabled_users) currently_enabled = set(item_list) toggle.enabled_users = item_list toggle.save() changed_entries = previously_enabled ^ currently_enabled # ^ means XOR self.call_save_fn(changed_entries, currently_enabled) for item in changed_entries: clear_toggle_cache(toggle.slug, item) data = { 'item_list': item_list } return HttpResponse(json.dumps(data), content_type="application/json")
def tearDown(self): clear_toggle_cache(MODULE_FILTER.slug, 'domain', NAMESPACE_DOMAIN)
def tearDownClass(cls): clear_toggle_cache(MOBILE_UCR.slug, cls.domain, NAMESPACE_DOMAIN)
def __exit__(self, exc_type, exc_val, exc_tb): clear_toggle_cache(self.toggle_slug, self.item, self.namespace)
def tearDownClass(cls): clear_toggle_cache(MOBILE_UCR.slug, cls.domain, NAMESPACE_DOMAIN) super(ReportFiltersSuiteTest, cls).tearDownClass()
def tearDown(self): clear_toggle_cache(toggles.CUSTOM_PROPERTIES.slug, 'potter', toggles.NAMESPACE_DOMAIN)
def tearDown(self): clear_toggle_cache(FILE_RESTORE.slug, USERNAME) super(FileRestoreSyncTokenCachingTest, self).tearDown()
def tearDown(self): self.suite_xml_is_usercase_in_use_patch.stop() clear_toggle_cache(MODULE_FILTER.slug, 'skelly', NAMESPACE_DOMAIN) clear_toggle_cache(MODULE_FILTER.slug, 'domain', NAMESPACE_DOMAIN) clear_toggle_cache(MODULE_FILTER.slug, 'example', NAMESPACE_DOMAIN)
def do_teardown(cls): for user in cls.users: user.delete() cls.project.delete() clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, TEST_DOMAIN, toggles.NAMESPACE_DOMAIN) FormProcessorTestUtils.delete_all_cases_forms_ledgers(TEST_DOMAIN)
def tearDown(self): clear_toggle_cache(toggles.FILE_RESTORE.slug, DUMMY_USERNAME) super(FileRestoreOtaRestoreTest, self).tearDown()
def tearDown(self): clear_toggle_cache(toggles.FILE_RESTORE.slug, self.user.username)
def tearDownClass(cls): cls.user.delete() clear_toggle_cache(toggles.CLOUDCARE_CACHE.slug, cls.domain, toggles.NAMESPACE_DOMAIN) FormProcessorTestUtils.delete_all_cases_forms_ledgers(cls.domain) cls.project.delete() super(CaseAPIMiscTests, cls).tearDownClass()
def setUp(self): self.project = Domain(name=self.domain) self.project.save() clear_toggle_cache(OLD_EXPORTS.slug, self.domain, namespace=NAMESPACE_DOMAIN) set_toggle(OLD_EXPORTS.slug, self.domain, True, namespace=NAMESPACE_DOMAIN)