コード例 #1
0
ファイル: subscribers.py プロジェクト: zermelozf/h
def remove_old_flags(event):
    """Remove old feature flags from the database."""
    # Skip this if we're in a script, not actual app startup. See the comment
    # in h.cli:main for an explanation.
    if 'H_SCRIPT' in os.environ:
        return

    engine = db.make_engine(event.app.registry.settings)
    session = db.Session(bind=engine)
    Feature.remove_old_flags(session)
    session.commit()
    session.close()
    engine.dispose()
コード例 #2
0
ファイル: models_test.py プロジェクト: zermelozf/h
    def test_all_only_returns_current_flags(self, db_session):
        """The .all() method should only return named current feature flags."""
        new, pending, old = [
            Feature(name='notification'),
            Feature(name='abouttoberemoved'),
            Feature(name='somethingelse')
        ]
        db_session.add_all([new, pending, old])
        db_session.flush()

        features = Feature.all(db_session)

        assert len(features) == 1
        assert features[0].name == 'notification'
コード例 #3
0
ファイル: feature_test.py プロジェクト: gnott/h
    def test_remove_old_flag_removes_old_flags(self, db_session):
        """
        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, pending, old = [Feature(name='notification'),
                             Feature(name='abouttoberemoved'),
                             Feature(name='somethingelse')]
        db_session.add_all([new, pending, old])
        db_session.flush()

        Feature.remove_old_flags(db_session)

        remaining = set([f.name for f in db_session.query(Feature).all()])
        assert remaining == {'abouttoberemoved', 'notification'}
コード例 #4
0
ファイル: models_test.py プロジェクト: zermelozf/h
    def test_remove_old_flag_removes_old_flags(self, db_session):
        """
        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, pending, old = [
            Feature(name='notification'),
            Feature(name='abouttoberemoved'),
            Feature(name='somethingelse')
        ]
        db_session.add_all([new, pending, old])
        db_session.flush()

        Feature.remove_old_flags(db_session)

        remaining = set([f.name for f in db_session.query(Feature).all()])
        assert remaining == {'abouttoberemoved', 'notification'}
コード例 #5
0
ファイル: feature_test.py プロジェクト: gnott/h
    def test_all_only_returns_current_flags(self, db_session):
        """The .all() method should only return named current feature flags."""
        new, pending, old = [Feature(name='notification'),
                             Feature(name='abouttoberemoved'),
                             Feature(name='somethingelse')]
        db_session.add_all([new, pending, old])
        db_session.flush()

        features = Feature.all(db_session)

        assert len(features) == 1
        assert features[0].name == 'notification'
コード例 #6
0
ファイル: client_test.py プロジェクト: ssin122/test-h
 def fetcher(self, cohort):
     return mock.Mock(spec_set=[],
                      return_value=[
                          Feature(name='foo'),
                          Feature(name='bar'),
                          Feature(name='on-for-everyone', everyone=True),
                          Feature(name='on-for-staff', staff=True),
                          Feature(name='on-for-admins', admins=True),
                          Feature(name='on-for-cohort', cohorts=[cohort])
                      ])
コード例 #7
0
ファイル: models_test.py プロジェクト: zermelozf/h
    def test_all_creates_annotations_that_dont_exist(self, db_session):
        features = Feature.all(db_session)

        assert len(features) == 1
        assert features[0].name == 'notification'
コード例 #8
0
ファイル: models_test.py プロジェクト: zermelozf/h
    def test_description_returns_hardcoded_description(self):
        feat = Feature(name='notification')

        assert feat.description == 'A test flag for testing with.'
コード例 #9
0
ファイル: feature_test.py プロジェクト: gnott/h
    def test_all_creates_annotations_that_dont_exist(self, db_session):
        features = Feature.all(db_session)

        assert len(features) == 1
        assert features[0].name == 'notification'