diff --git a/humbug/test_settings.py b/humbug/test_settings.py index 78b4359f9d..973cab49f3 100644 --- a/humbug/test_settings.py +++ b/humbug/test_settings.py @@ -39,12 +39,9 @@ TUTORIAL_ENABLED = False # Disable use of memcached for caching CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', - 'LOCATION': 'humbug-default-test-cache', - 'TIMEOUT': 3600, - 'OPTIONS': { - 'MAX_ENTRIES': 100000 - }, + 'BACKEND': 'django.core.cache.backends.memcached.PyLibMCCache', + 'LOCATION': '127.0.0.1:11211', + 'TIMEOUT': 3600 }, 'database': { 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', diff --git a/zephyr/lib/cache.py b/zephyr/lib/cache.py index f7c757f0a9..03bf2e7fc9 100644 --- a/zephyr/lib/cache.py +++ b/zephyr/lib/cache.py @@ -63,6 +63,10 @@ def get_or_create_key_prefix(): KEY_PREFIX = get_or_create_key_prefix() +def bounce_key_prefix_for_testing(test_name): + global KEY_PREFIX + KEY_PREFIX = test_name + ':' + str(os.getpid()) + ':' + def get_cache_backend(cache_name): if cache_name is None: return djcache diff --git a/zephyr/tests.py b/zephyr/tests.py index 8682da702e..130b150a15 100644 --- a/zephyr/tests.py +++ b/zephyr/tests.py @@ -16,6 +16,7 @@ from zephyr.lib.actions import do_send_message, gather_subscriptions, \ create_stream_if_needed, do_add_subscription from zephyr.lib.rate_limiter import add_ratelimit_rule, remove_ratelimit_rule from zephyr.lib import bugdown +from zephyr.lib.cache import bounce_key_prefix_for_testing from zephyr.lib.rate_limiter import clear_user_history from django.conf import settings @@ -1404,12 +1405,16 @@ so we didn't send them an invitation. We did send invitations to everyone else!" # We only sent emails to the new users. self.check_sent_emails(new) - @slow(0.35, 'inviting is slow') - def test_invite_outside_domain_in_open_realm(self): + @slow(0.20, 'inviting is slow') + def test_invite_outside_domain_in_closed_realm(self): """ - In a realm with `restricted_to_domain = False`, you can invite people + In a realm with `restricted_to_domain = True`, you can't invite people with a different domain from that of the realm or your e-mail address. """ + humbug_realm = Realm.objects.get(domain="humbughq.com") + humbug_realm.restricted_to_domain = True + humbug_realm.save() + self.login("hamlet@humbughq.com") external_address = "foo@example.com" @@ -1417,10 +1422,19 @@ so we didn't send them an invitation. We did send invitations to everyone else!" self.invite(external_address, ["Denmark"]), "Some emails did not validate, so we didn't send any invitations.") + @slow(0.20, 'inviting is slow') + def test_invite_outside_domain_in_open_realm(self): + """ + In a realm with `restricted_to_domain = False`, you can invite people + with a different domain from that of the realm or your e-mail address. + """ humbug_realm = Realm.objects.get(domain="humbughq.com") humbug_realm.restricted_to_domain = False humbug_realm.save() + self.login("hamlet@humbughq.com") + external_address = "foo@example.com" + self.assert_json_success(self.invite(external_address, ["Denmark"])) self.check_sent_emails([external_address]) @@ -3008,6 +3022,9 @@ def run_test(test): return test_name = full_test_name(test) + + bounce_key_prefix_for_testing(test_name) + print 'Running %s' % (test_name,) test._pre_setup()