Permalink
Browse files

create waffle flags in cache only

  • Loading branch information...
1 parent 334d038 commit ee2610c211db636290a84bf8d15bbd4b4f2404e9 @andymckay andymckay committed Nov 17, 2012
Showing with 8 additions and 5 deletions.
  1. +8 −5 apps/amo/tests/__init__.py
View
@@ -23,6 +23,7 @@
from nose.exc import SkipTest
from nose.tools import eq_, nottest
from redisutils import mock_redis, reset_redis
+from waffle import cache_sample, cache_switch
from waffle.models import Flag, Sample, Switch
import addons.search
@@ -385,17 +386,19 @@ def make_premium(self, addon, currencies=None):
addon.update(premium_type=amo.ADDON_PREMIUM)
AddonPremium.objects.create(addon=addon, price=price)
- def create_sample(self, name=None, **kw):
+ def create_sample(self, name=None, db=False, **kw):
if name is not None:
kw['name'] = name
kw.setdefault('percent', 100)
- Sample.objects.create(**kw)
+ sample = Sample(**kw)
+ sample.save() if db else cache_sample(instance=sample)
- def create_switch(self, name=None, **kw):
+ def create_switch(self, name=None, db=False, **kw):
+ kw.setdefault('active', True)
if name is not None:
kw['name'] = name
- kw.setdefault('active', True)
- Switch.objects.create(**kw)
+ switch = Switch(**kw)
+ switch.save() if db else cache_switch(instance=switch)
def create_flag(self, name=None, **kw):
if name is not None:

0 comments on commit ee2610c

Please sign in to comment.