def test_getAllRulesAsText(self): source = StormFeatureRuleSource() source.setAllRules(test_rules_list) self.assertEquals( """\ %s\tbeta_user\t100\t%s ui.icing\tnormal_user\t500\t5.0 ui.icing\tbeta_user\t300\t4.0 ui.icing\tdefault\t100\t3.0 """ % (notification_name, notification_value), source.getAllRulesAsText())
def test_getAllRulesAsText(self): source = StormFeatureRuleSource() source.setAllRules(test_rules_list) self.assertEquals( """\ %s\tbeta_user\t100\t%s ui.icing\tnormal_user\t500\t5.0 ui.icing\tbeta_user\t300\t4.0 ui.icing\tdefault\t100\t3.0 """ % (notification_name, notification_value), source.getAllRulesAsText(), )
def test_setAllRulesFromText(self): # We will overwrite existing data. source = StormFeatureRuleSource() source.setAllRules(test_rules_list) source.setAllRulesFromText( """ flag1 beta_user 200 alpha flag1 default 100 gamma with spaces flag2 default 0\ton """ ) self.assertEquals( { "flag1": [("beta_user", 200, "alpha"), ("default", 100, "gamma with spaces")], "flag2": [("default", 0, "on")], }, source.getAllRulesAsDict(), )
def setUp(self): """Set the feature flags that this fixture is responsible for.""" super(FeatureFixture, self).setUp() rule_source = StormFeatureRuleSource() self.addCleanup( rule_source.setAllRules, rule_source.getAllRulesAsTuples()) rule_source.setAllRules(self.makeNewRules()) original_controller = get_relevant_feature_controller() def scope_lookup(scope_name): request = get_current_browser_request() return ScopesFromRequest(request).lookup(scope_name) if self.override_scope_lookup: scope_lookup = self.override_scope_lookup install_feature_controller( FeatureController(scope_lookup, rule_source)) self.addCleanup(install_feature_controller, original_controller)
def setUp(self): """Set the feature flags that this fixture is responsible for.""" super(FeatureFixture, self).setUp() rule_source = StormFeatureRuleSource() self.addCleanup(rule_source.setAllRules, rule_source.getAllRulesAsTuples()) rule_source.setAllRules(self.makeNewRules()) original_controller = get_relevant_feature_controller() def scope_lookup(scope_name): request = get_current_browser_request() return ScopesFromRequest(request).lookup(scope_name) if self.override_scope_lookup: scope_lookup = self.override_scope_lookup install_feature_controller(FeatureController(scope_lookup, rule_source)) self.addCleanup(install_feature_controller, original_controller)
def test_setAllRulesFromText(self): # We will overwrite existing data. source = StormFeatureRuleSource() source.setAllRules(test_rules_list) source.setAllRulesFromText(""" flag1 beta_user 200 alpha flag1 default 100 gamma with spaces flag2 default 0\ton """) self.assertEquals( { 'flag1': [ ('beta_user', 200, 'alpha'), ('default', 100, 'gamma with spaces'), ], 'flag2': [ ('default', 0, 'on'), ], }, source.getAllRulesAsDict())
def test_getAllRulesAsTuples(self): source = StormFeatureRuleSource() source.setAllRules(test_rules_list) self.assertEquals(test_rules_list, list(source.getAllRulesAsTuples()))