def test_search_landing(self): def commenthandler(bug, bugid, data): data['comments'] = bug['comments'] data = {} bugzilla.Bugzilla(538189, commenthandler=commenthandler, commentdata=data).get_data().wait() inbound = bugzilla.Bugzilla.get_landing_comments(data['comments'], 'inbound') self.assertEqual(len(inbound), 1) self.assertEqual(inbound[0]['revision'], '42c54c7cb4a3') self.assertEqual(inbound[0]['comment'], {'attachment_id': None, 'raw_text': 'http://hg.mozilla.org/integration/mozilla-inbound/rev/42c54c7cb4a3', 'tags': [], 'is_private': False, 'creator': '*****@*****.**', 'bug_id': 538189, 'author': '*****@*****.**', 'text': 'http://hg.mozilla.org/integration/mozilla-inbound/rev/42c54c7cb4a3', 'id': 5655196, 'creation_time': '2011-08-15T21:21:13Z', 'time': '2011-08-15T21:21:13Z'}) central = bugzilla.Bugzilla.get_landing_comments(data['comments'], 'central') self.assertEqual(len(central), 1) self.assertEqual(central[0]['revision'], '42c54c7cb4a3') self.assertEqual(central[0]['comment'], {'attachment_id': None, 'raw_text': 'http://hg.mozilla.org/mozilla-central/rev/42c54c7cb4a3\n\nAsa, did you mean to set approval-beta+ instead of approval-beta?', 'tags': [], 'is_private': False, 'creator': '*****@*****.**', 'bug_id': 538189, 'author': '*****@*****.**', 'text': 'http://hg.mozilla.org/mozilla-central/rev/42c54c7cb4a3\n\nAsa, did you mean to set approval-beta+ instead of approval-beta?', 'id': 5656549, 'creation_time': '2011-08-16T11:02:36Z', 'time': '2011-08-16T11:02:36Z'}) beta = bugzilla.Bugzilla.get_landing_comments(data['comments'], 'beta') self.assertEqual(len(beta), 1) self.assertEqual(beta[0]['revision'], '1d02edaa92bc') self.assertEqual(beta[0]['comment'], {'attachment_id': None, 'raw_text': 'http://hg.mozilla.org/releases/mozilla-beta/rev/1d02edaa92bc', 'tags': [], 'is_private': False, 'creator': '*****@*****.**', 'bug_id': 538189, 'author': '*****@*****.**', 'text': 'http://hg.mozilla.org/releases/mozilla-beta/rev/1d02edaa92bc', 'id': 5686198, 'creation_time': '2011-08-29T21:55:57Z', 'time': '2011-08-29T21:55:57Z'}) multiple = bugzilla.Bugzilla.get_landing_comments(data['comments'], ['beta', 'inbound', 'central']) self.assertEqual(multiple, [{'revision': '42c54c7cb4a3', 'channel': 'inbound', 'comment': {'creation_time': '2011-08-15T21:21:13Z', 'is_private': False, 'attachment_id': None, 'text': 'http://hg.mozilla.org/integration/mozilla-inbound/rev/42c54c7cb4a3', 'creator': '*****@*****.**', 'tags': [], 'bug_id': 538189, 'author': '*****@*****.**', 'time': '2011-08-15T21:21:13Z', 'id': 5655196, 'raw_text': 'http://hg.mozilla.org/integration/mozilla-inbound/rev/42c54c7cb4a3'}}, {'revision': '42c54c7cb4a3', 'channel': 'central', 'comment': {'creation_time': '2011-08-16T11:02:36Z', 'is_private': False, 'attachment_id': None, 'text': 'http://hg.mozilla.org/mozilla-central/rev/42c54c7cb4a3\n\nAsa, did you mean to set approval-beta+ instead of approval-beta?', 'creator': '*****@*****.**', 'tags': [], 'bug_id': 538189, 'author': '*****@*****.**', 'time': '2011-08-16T11:02:36Z', 'id': 5656549, 'raw_text': 'http://hg.mozilla.org/mozilla-central/rev/42c54c7cb4a3\n\nAsa, did you mean to set approval-beta+ instead of approval-beta?'}}, {'revision': '1d02edaa92bc', 'channel': 'beta', 'comment': {'creation_time': '2011-08-29T21:55:57Z', 'is_private': False, 'attachment_id': None, 'text': 'http://hg.mozilla.org/releases/mozilla-beta/rev/1d02edaa92bc', 'creator': '*****@*****.**', 'tags': [], 'bug_id': 538189, 'author': '*****@*****.**', 'time': '2011-08-29T21:55:57Z', 'id': 5686198, 'raw_text': 'http://hg.mozilla.org/releases/mozilla-beta/rev/1d02edaa92bc'}}]) data = {} bugzilla.Bugzilla(679352, commenthandler=commenthandler, commentdata=data).get_data().wait() central = bugzilla.Bugzilla.get_landing_comments(data['comments'], 'central') self.assertEqual(len(central), 8)
def test_search_dict(self): def bughandler(bug, data): data[bug['id']] = bug bugs = {} # Unique bug id terms = { 'bug_id': 12345, 'bug_id_type': 'anyexact', 'list_id': 12958345, 'resolution': 'FIXED', 'query_format': 'advanced', } bugzilla.Bugzilla(terms, bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(len(bugs), 1) self.assertEqual(bugs[12345]['id'], 12345) bugs = {} # Mutiple bugs terms = { 'bug_id': [12345, 12346], 'bug_id_type': 'anyexact', 'list_id': 12958345, 'resolution': 'FIXED', 'query_format': 'advanced', } bugzilla.Bugzilla(terms, bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(len(bugs), 2) self.assertEqual(bugs[12345]['id'], 12345) self.assertEqual(bugs[12346]['id'], 12346) bugs = {} # Mutiple queries terms = [ { 'bug_id': 12345, }, { 'bug_id': 12346, }, ] bugzilla.Bugzilla(terms, bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(len(bugs), 2) self.assertEqual(bugs[12345]['id'], 12345) self.assertEqual(bugs[12346]['id'], 12346)
def test_include_fields(self): def attachmenthandler(bug, bugid, data): data['attachment'] = bug data = {} bugzilla.Bugzilla(12345, attachmenthandler=attachmenthandler, attachmentdata=data, attachment_include_fields=['description']).get_data().wait() self.assertEqual(data['attachment'][0]['description'], 'Some patch.') self.assertNotIn('is_patch', data['attachment'][0]) self.assertNotIn('is_obsolete', data['attachment'][0])
def test_search(self): def bughandler(bug, data): data[bug['id']] = bug bugs = {} bugzilla.Bugzilla('bug_id=12345%2C12346&bug_id_type=anyexact&list_id=12958345&resolution=FIXED&query_format=advanced', bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(bugs[12345]['id'], 12345) self.assertEqual(bugs[12346]['id'], 12346)
def test_bugid(self): def bughandler(bug, data): data.update(bug) bug = {} bugzilla.Bugzilla(12345, bughandler=bughandler, bugdata=bug).get_data().wait() self.assertEqual(bug['id'], 12345) self.assertEqual(bug['resolution'], u'FIXED') self.assertEqual(bug['assigned_to'], u'*****@*****.**') self.assertEqual(bug['summary'], u'[DOGFOOD] Unable to Forward a message received as an Inline page or an attachment')
def test_search_multiple(self): def bughandler(bug, data): data[bug['id']] = bug bugs = {} bugzilla.Bugzilla(['bug_id=12345%2C12346%2C12347', 'bug_id=12348%2C12349%2C12350'], bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(bugs[12345]['id'], 12345) self.assertEqual(bugs[12346]['id'], 12346) self.assertEqual(bugs[12347]['id'], 12347) self.assertEqual(bugs[12348]['id'], 12348) self.assertEqual(bugs[12349]['id'], 12349) self.assertEqual(bugs[12350]['id'], 12350)
def test_search_only_attachment(self): def bughandler(bug, data): data['bug'] = bug def attachmenthandler(bug, bugid, data): data['attachment'] = bug data = {} bugzilla.Bugzilla('bug_id=12345', bughandler=bughandler, bugdata=data, attachmenthandler=attachmenthandler, attachmentdata=data).get_data().wait() self.assertEqual(data['bug']['id'], 12345) self.assertEqual(len(data['attachment']), 1) self.assertEqual(data['attachment'][0]['description'], 'Some patch.') self.assertEqual(data['attachment'][0]['is_patch'], 1) self.assertEqual(data['attachment'][0]['is_obsolete'], 1)
def test_search_history(self): def historyhandler(bug, data): data['history'] = bug['history'] data = {} bugzilla.Bugzilla(12345, historyhandler=historyhandler, historydata=data).get_data().wait() all = bugzilla.Bugzilla.get_history_matches(data['history'], {}) self.assertEqual(len(all), len(data['history'])) change_to_assigned = bugzilla.Bugzilla.get_history_matches(data['history'], {'added': 'ASSIGNED'}) self.assertEqual(change_to_assigned, [{'when': '1999-08-29T17:43:15Z', 'changes': [{'added': 'ASSIGNED', 'field_name': 'status', 'removed': 'NEW'}], 'who': '*****@*****.**'}]) blocks_changes = bugzilla.Bugzilla.get_history_matches(data['history'], {'field_name': 'blocks'}) self.assertEqual(blocks_changes, [{'changes': [{'removed': '', 'added': '11091', 'field_name': 'blocks'}], 'who': '*****@*****.**', 'when': '1999-09-20T22:58:39Z'}, {'changes': [{'removed': '', 'added': '17976', 'field_name': 'blocks'}], 'who': '*****@*****.**', 'when': '1999-11-04T14:05:18Z'}]) single_block_change = bugzilla.Bugzilla.get_history_matches(data['history'], {'added': '11091', 'field_name': 'blocks'}) self.assertEqual(single_block_change, [{'changes': [{'removed': '', 'added': '11091', 'field_name': 'blocks'}], 'who': '*****@*****.**', 'when': '1999-09-20T22:58:39Z'}]) data = {} bugzilla.Bugzilla(1005958, historyhandler=historyhandler, historydata=data).get_data().wait() multiple_changes = bugzilla.Bugzilla.get_history_matches(data['history'], {'added': 'approval-mozilla-release?'}) self.assertEqual(multiple_changes, [{'changes': [{'added': 'approval-mozilla-aurora?, approval-mozilla-beta?, approval-mozilla-release?', 'attachment_id': 8417443, 'field_name': 'flagtypes.name', 'removed': ''}], 'when': '2014-05-05T20:25:06Z', 'who': '*****@*****.**'}])
def test_bugids(self): def bughandler(bug, data): data[bug['id']] = bug bugs = {} bugzilla.Bugzilla([12345, 12346], bughandler=bughandler, bugdata=bugs).get_data().wait() self.assertEqual(bugs[12345]['id'], 12345) self.assertEqual(bugs[12345]['resolution'], u'FIXED') self.assertEqual(bugs[12345]['assigned_to'], u'*****@*****.**') self.assertEqual(bugs[12345]['summary'], u'[DOGFOOD] Unable to Forward a message received as an Inline page or an attachment') self.assertEqual(bugs[12346]['id'], 12346) self.assertEqual(bugs[12346]['resolution'], u'FIXED') self.assertEqual(bugs[12346]['assigned_to'], u'*****@*****.**') self.assertEqual(bugs[12346]['summary'], u'nsOutputFileStream should buffer the output')
def test_search(self): def bughandler(bug, data): data['bug'] = bug def commenthandler(bug, bugid, data): data['comment'] = bug['comments'] def historyhandler(bug, data): data['history'] = bug data = {} bugzilla.Bugzilla('bug_id=12345', bughandler=bughandler, bugdata=data, commenthandler=commenthandler, commentdata=data, historyhandler=historyhandler, historydata=data).get_data().wait() self.assertEqual(data['bug']['id'], 12345) self.assertEqual(len(data['comment']), 19) self.assertTrue(data['comment'][0]['text'].startswith(u'Steps to reproduce')) self.assertEqual(len(data['history']['history']), 24)
def test_bugid(self): def bughandler(bug, data): data['bug'] = bug def commenthandler(bug, bugid, data): data['comment'] = bug['comments'] def historyhandler(bug, data): data['history'] = bug def attachmenthandler(bug, bugid, data): data['attachment'] = bug data = {} bugzilla.Bugzilla(12345, bughandler=bughandler, bugdata=data, commenthandler=commenthandler, commentdata=data, historyhandler=historyhandler, historydata=data, attachmenthandler=attachmenthandler, attachmentdata=data).get_data().wait() self.assertEqual(data['bug']['id'], 12345) self.assertEqual(len(data['comment']), 19) self.assertTrue(data['comment'][0]['text'].startswith(u'Steps to reproduce')) self.assertEqual(len(data['history']['history']), 24) self.assertEqual(len(data['attachment']), 1) self.assertEqual(data['attachment'][0]['description'], 'Some patch.') self.assertEqual(data['attachment'][0]['is_patch'], 1) self.assertEqual(data['attachment'][0]['is_obsolete'], 1)