コード例 #1
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
    def test_load_skips_pending_removal_features(self, client):
        db.Session.add(features.Feature(name='notification'))
        db.Session.add(features.Feature(name='abouttoberemoved'))
        db.Session.flush()

        client.load()
        assert client._cache.keys() == ['notification']
コード例 #2
0
def test_remove_old_flag_removes_old_flags():
    new_feature = features.Feature(name='notification')
    old_feature = features.Feature(name='somethingelse')
    db.Session.add(new_feature, old_feature)
    db.Session.flush()

    features.remove_old_flags()

    remaining = [f.name for f in features.Feature.query.all()]
    assert remaining == ['notification']
コード例 #3
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
    def test_load_skips_database_features_missing_from_dict(self, client):
        """
        Test that load does not load features that are still in the database
        but not in the FEATURES dict anymore
        """
        db.Session.add(features.Feature(name='notification'))
        db.Session.add(features.Feature(name='new_homepage'))
        db.Session.flush()

        client.load()
        assert client._cache.keys() == ['notification']
コード例 #4
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
    def test_enabled_false_when_staff_true_normal_request(
            self, client, fetcher):
        fetcher.return_value = [
            features.Feature(name='notification', staff=True)
        ]

        assert client.enabled('notification') is False
コード例 #5
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
 def test_enabled_true_when_admins_true_admin_request(
         self, client, fetcher, authn_policy):
     authn_policy.effective_principals.return_value = [role.Admin]
     fetcher.return_value = [
         features.Feature(name='notification', admins=True)
     ]
     assert client.enabled('notification') is True
コード例 #6
0
ファイル: features_test.py プロジェクト: hashin/h
def test_remove_old_flag_removes_old_flags():
    """
    The remove_old_flags function should remove unknown flags.

    New flags and flags pending removal should be left alone, but completely
    unknown flags should be removed.
    """
    new_feature = features.Feature(name='notification')
    pending_feature = features.Feature(name='abouttoberemoved')
    old_feature = features.Feature(name='somethingelse')
    db.Session.add_all([new_feature, pending_feature, old_feature])
    db.Session.flush()

    features.remove_old_flags()

    remaining = set([f.name for f in features.Feature.query.all()])
    assert remaining == {'abouttoberemoved', 'notification'}
コード例 #7
0
    def test_init_skips_database_features_missing_from_dict(self):
        """
        Test that init does not load features that are still in the database
        but not in the FEATURES dict anymore
        """
        db.Session.add(features.Feature(name='new_homepage'))
        db.Session.flush()

        client = self.client()
        assert len(client._cache) == 0
コード例 #8
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
 def test_enabled_false_if_everyone_false(self, client, fetcher):
     fetcher.return_value = [
         features.Feature(name='notification', everyone=False)
     ]
     assert client.enabled('notification') is False
コード例 #9
0
ファイル: features_test.py プロジェクト: Cinemacloud/h
    def test_load_loads_features(self, client):
        db.Session.add(features.Feature(name='notification'))
        db.Session.flush()

        client.load()
        assert client._cache.keys() == ['notification']
コード例 #10
0
 def test_enabled_true_when_staff_true_staff_request(
         self, client, authn_policy):
     client._cache['notification'] = features.Feature(staff=True)
     authn_policy.effective_principals.return_value = [role.Staff]
     assert client.enabled('notification') == True
コード例 #11
0
 def test_enabled_false_when_staff_true_normal_request(self, client):
     client._cache['notification'] = features.Feature(staff=True)
     assert client.enabled('notification') == False
コード例 #12
0
 def test_enabled_true_if_everyone_true(self, client):
     client._cache['notification'] = features.Feature(everyone=True)
     assert client.enabled('notification') == True
コード例 #13
0
 def test_enabled_false_if_everyone_false(self, client):
     client._cache['notification'] = features.Feature(everyone=False)
     assert client.enabled('notification') == False
コード例 #14
0
    def test_init_skips_pending_removal_features(self):
        db.Session.add(features.Feature(name='abouttoberemoved'))
        db.Session.flush()

        client = self.client()
        assert len(client._cache) == 0