예제 #1
0
 def test_ChangeLog_get(self):
     # The get() method returns an iterator of FeatureFlagChanges from
     # newest to oldest.
     feature_flag_change_1 = ChangeLog.append(diff, 'comment', self.person)
     feature_flag_change_2 = ChangeLog.append(diff, 'comment', self.person)
     results = ChangeLog.get()
     self.assertEqual(
         [feature_flag_change_2, feature_flag_change_1], list(results))
예제 #2
0
 def change_action(self, action, data):
     original_rules = self.request.features.rule_source.getAllRulesAsText()
     rules_text = data.get('feature_rules') or ''
     logger = logging.getLogger(self.logger_name)
     logger.warning("Change feature rules to: %s" % (rules_text, ))
     logger.warning("Previous feature rules were: %s" % (original_rules, ))
     self.request.features.rule_source.setAllRulesFromText(rules_text)
     # Why re-fetch the rules here?  This way we get them reformatted
     # (whitespace normalized) and ordered consistently so the diff is
     # minimal.
     new_rules = self.request.features.rule_source.getAllRulesAsText()
     diff = u'\n'.join(self.diff_rules(original_rules, new_rules))
     comment = data['comment']
     ChangeLog.append(diff, comment, self.user)
     self.diff = FormattersAPI(diff).format_diff()
예제 #3
0
 def change_action(self, action, data):
     original_rules = self.request.features.rule_source.getAllRulesAsText()
     rules_text = data.get('feature_rules') or ''
     logger = logging.getLogger(self.logger_name)
     logger.warning("Change feature rules to: %s" % (rules_text,))
     logger.warning("Previous feature rules were: %s" % (original_rules,))
     self.request.features.rule_source.setAllRulesFromText(rules_text)
     # Why re-fetch the rules here?  This way we get them reformatted
     # (whitespace normalized) and ordered consistently so the diff is
     # minimal.
     new_rules = self.request.features.rule_source.getAllRulesAsText()
     diff = u'\n'.join(self.diff_rules(original_rules, new_rules))
     comment = data['comment']
     ChangeLog.append(diff, comment, self.user)
     self.diff = FormattersAPI(diff).format_diff()
예제 #4
0
 def test_ChangeLog_append(self):
     # The append() method creates a FeatureFlagChangelogEntry.
     feature_flag_change = ChangeLog.append(diff, 'comment', self.person)
     self.assertEqual(
         diff, feature_flag_change.diff)
     self.assertEqual(
         'comment', feature_flag_change.comment)
     self.assertEqual(
         self.person, feature_flag_change.person)
예제 #5
0
 def test_feature_page_submit_changes(self):
     """Submitted changes show up in the db."""
     browser = self.getUserBrowserAsAdmin()
     browser.open(self.getFeatureRulesEditURL())
     new_value = 'beta_user some_key 10 some value with spaces'
     textarea = browser.getControl(name="field.feature_rules")
     textarea.value = new_value
     browser.getControl(name="field.comment").value = 'Bob is testing.'
     browser.getControl(name="field.actions.change").click()
     self.assertThat(
         list(StormFeatureRuleSource().getAllRulesAsTuples()),
         Equals([
             ('beta_user', 'some_key', 10, 'some value with spaces'),
         ]))
     changes = list(ChangeLog.get())
     self.assertEqual(1, len(changes))
     self.assertEqual('+beta_user\tsome_key\t10\tsome value with spaces',
                      changes[0].diff)
     self.assertEqual('Bob is testing.', changes[0].comment)
     self.assertEqual(self.user, changes[0].person)
 def test_feature_page_submit_changes(self):
     """Submitted changes show up in the db."""
     browser = self.getUserBrowserAsAdmin()
     browser.open(self.getFeatureRulesEditURL())
     new_value = 'beta_user some_key 10 some value with spaces'
     textarea = browser.getControl(name="field.feature_rules")
     textarea.value = new_value
     browser.getControl(name="field.comment").value = 'Bob is testing.'
     browser.getControl(name="field.actions.change").click()
     self.assertThat(
         list(StormFeatureRuleSource().getAllRulesAsTuples()),
         Equals([
             ('beta_user', 'some_key', 10, 'some value with spaces'),
             ]))
     changes = list(ChangeLog.get())
     self.assertEqual(1, len(changes))
     self.assertEqual(
         '+beta_user\tsome_key\t10\tsome value with spaces',
         changes[0].diff)
     self.assertEqual('Bob is testing.', changes[0].comment)
     self.assertEqual(self.user, changes[0].person)
예제 #7
0
 def makeFeatureFlagChanges(self):
     for i in range(0, 11):
         ChangeLog.append(
             diff % dict(idx=i), 'comment %s' % i, self.person)
예제 #8
0
 def changes(self):
     navigator = BatchNavigator(ChangeLog.get(), self.request, size=10)
     navigator.setHeadings('change', 'changes')
     return navigator
예제 #9
0
 def makeFeatureFlagChanges(self):
     for i in range(0, 11):
         ChangeLog.append(diff % dict(idx=i), 'comment %s' % i, self.person)
예제 #10
0
 def changes(self):
     navigator = BatchNavigator(ChangeLog.get(), self.request, size=10)
     navigator.setHeadings('change', 'changes')
     return navigator