示例#1
0
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
    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
    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
 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
    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
    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'