def get(self): """Renders the UI with all of the forms.""" patterns_dict = bug_label_patterns.GetBugLabelPatterns() self.RenderHtml('edit_bug_labels.html', { 'bug_labels': sorted(patterns_dict), 'bug_labels_json': json.dumps(patterns_dict, indent=2, sort_keys=True) })
def testRemoveBugLabel(self): bug_label_patterns.AddBugLabelPattern('foo', '*/*/foo') bug_label_patterns.AddBugLabelPattern('bar', '*/*/bar') bug_label_patterns.AddBugLabelPattern('bar', '*/*/bar-extra') bug_label_patterns.RemoveBugLabel('bar') self.assertEqual({'foo': ['*/*/foo']}, bug_label_patterns.GetBugLabelPatterns())
def testAddBugLabelPattern(self): bug_label_patterns.AddBugLabelPattern('foo', '*/*/foo') bug_label_patterns.AddBugLabelPattern('bar', '*/*/bar') bug_label_patterns.AddBugLabelPattern('bar', '*/*/bar-extra') self.assertEqual( 1, len(bug_label_patterns.BugLabelPatterns.query().fetch())) self.assertEqual( {'foo': ['*/*/foo'], 'bar': ['*/*/bar', '*/*/bar-extra']}, bug_label_patterns.GetBugLabelPatterns())
def testBugLabelPattern(self): """Tests adding and removing a BugLabelPattern.""" self.testapp.post( '/edit_bug_labels', { 'action': 'add_buglabel_pattern', 'buglabel_to_add': 'Performance-1', 'pattern': '*/*/Suite1/*', 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), }) # The list of patterns should now contain the pattern that was added. self.assertEqual( ['*/*/Suite1/*'], bug_label_patterns.GetBugLabelPatterns()['Performance-1']) # Add another pattern for the same bug label. self.testapp.post( '/edit_bug_labels', { 'action': 'add_buglabel_pattern', 'buglabel_to_add': 'Performance-1', 'pattern': '*/*/Suite2/*', 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), }) # The list of patterns should now contain both patterns. self.assertEqual( ['*/*/Suite1/*', '*/*/Suite2/*'], bug_label_patterns.GetBugLabelPatterns()['Performance-1']) # Remove the BugLabelPattern entity. self.testapp.post( '/edit_bug_labels', { 'action': 'remove_buglabel_pattern', 'buglabel_to_remove': 'Performance-1', 'xsrf_token': xsrf.GenerateToken(users.get_current_user()), }) # It should now be absent from the datastore. self.assertNotIn('Performance-1', bug_label_patterns.GetBugLabelPatterns())
def testRemoveBugLabel_DoesntExist_NoError(self): bug_label_patterns.RemoveBugLabel('bar') self.assertEqual({}, bug_label_patterns.GetBugLabelPatterns())