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))
Example #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()
Example #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()
 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)
Example #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)
 def makeFeatureFlagChanges(self):
     for i in range(0, 11):
         ChangeLog.append(
             diff % dict(idx=i), 'comment %s' % i, self.person)
Example #8
0
 def changes(self):
     navigator = BatchNavigator(ChangeLog.get(), self.request, size=10)
     navigator.setHeadings('change', 'changes')
     return navigator
Example #9
0
 def makeFeatureFlagChanges(self):
     for i in range(0, 11):
         ChangeLog.append(diff % dict(idx=i), 'comment %s' % i, self.person)
Example #10
0
 def changes(self):
     navigator = BatchNavigator(ChangeLog.get(), self.request, size=10)
     navigator.setHeadings('change', 'changes')
     return navigator