Beispiel #1
0
 def setUp(self):
     """
     Set up some items we can reuse.
     """
     self.backend = DjangoORMBackend()
Beispiel #2
0
class TestBackendDBDjango(TestCase):
    """
    Test the DjangoORMBackend class.
    """
    def setUp(self):
        """
        Set up some items we can reuse.
        """
        self.backend = DjangoORMBackend()

    def test_exists(self):
        """
        Verify Backend.exists returns proper info.
        """
        assert self.backend.exists('exists') is False
        # Create it and verify it now exists
        FlagonFeature(name='exists', active=True).save()
        assert self.backend.exists('exists')

    def test_is_active(self):
        """
        Verify Backend.is_active returns if the features is active.
        """
        FlagonFeature(name='active', active=True).save()
        FlagonFeature(name='notactive', active=False).save()
        assert self.backend.is_active('active')
        assert self.backend.is_active('notactive') is False

    def test_turn_on(self):
        """
        Verify Backend.turn_on turns a feature on.
        """
        FlagonFeature(name='wasoff', active=False).save()
        assert self.backend.is_active('wasoff') is False
        self.backend.turn_on('wasoff')
        assert self.backend.is_active('wasoff')

    def test_turn_off(self):
        """
        Verify Backend.turn_off turns a feature off.
        """
        FlagonFeature(name='wason', active=True).save()
        assert self.backend.is_active('wason')
        self.backend.turn_off('wason')
        assert self.backend.is_active('wason') is False

    def test_toggle(self):
        """
        Verify Backend.toggle flips the feature to it's reverse status.
        """
        FlagonFeature(name='toggle', active=True).save()
        assert self.backend.is_active('toggle')
        self.backend.toggle('toggle')
        assert self.backend.is_active('toggle') is False
        self.backend.toggle('toggle')
        assert self.backend.is_active('toggle')

    def test_is_off(self):
        """
        Verify Backend.is_off returns if the feature is off.
        """
        FlagonFeature(name='isnotoff', active=True).save()
        FlagonFeature(name='isoff', active=False).save()
        assert self.backend.is_off('isnotoff') is False
        assert self.backend.is_off('isoff')
class TestBackendDBDjango(TestCase):
    """
    Test the DjangoORMBackend class.
    """

    def setUp(self):
        """
        Set up some items we can reuse.
        """
        self.backend = DjangoORMBackend()

    def test_exists(self):
        """
        Verify Backend.exists returns proper info.
        """
        assert self.backend.exists('exists') is False
        # Create it and verify it now exists
        FlagonFeature(name='exists', active=True).save()
        assert self.backend.exists('exists')

    def test_is_active(self):
        """
        Verify Backend.is_active returns if the features is active.
        """
        FlagonFeature(name='active', active=True).save()
        FlagonFeature(name='notactive', active=False).save()
        assert self.backend.is_active('active')
        assert self.backend.is_active('notactive') is False

    def test_turn_on(self):
        """
        Verify Backend.turn_on turns a feature on.
        """
        FlagonFeature(name='wasoff', active=False).save()
        assert self.backend.is_active('wasoff') is False
        self.backend.turn_on('wasoff')
        assert self.backend.is_active('wasoff')

    def test_turn_off(self):
        """
        Verify Backend.turn_off turns a feature off.
        """
        FlagonFeature(name='wason', active=True).save()
        assert self.backend.is_active('wason')
        self.backend.turn_off('wason')
        assert self.backend.is_active('wason') is False

    def test_toggle(self):
        """
        Verify Backend.toggle flips the feature to it's reverse status.
        """
        FlagonFeature(name='toggle', active=True).save()
        assert self.backend.is_active('toggle')
        self.backend.toggle('toggle')
        assert self.backend.is_active('toggle') is False
        self.backend.toggle('toggle')
        assert self.backend.is_active('toggle')

    def test_is_off(self):
        """
        Verify Backend.is_off returns if the feature is off.
        """
        FlagonFeature(name='isnotoff', active=True).save()
        FlagonFeature(name='isoff', active=False).save()
        assert self.backend.is_off('isnotoff') is False
        assert self.backend.is_off('isoff')
 def setUp(self):
     """
     Set up some items we can reuse.
     """
     self.backend = DjangoORMBackend()
Beispiel #5
0
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Feature flags
import logging
from flagon.backends.db_django import DjangoORMBackend
from flagon.feature import Feature
# Make a backend
FEATURES = DjangoORMBackend()
FEATURE = Feature(FEATURES, logging.getLogger())

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/

STATIC_URL = '/static/'