示例#1
0
 def test_success(self):
     bug = {
         'commits': ['abcd123'],
         'needed_on': ['v1', 'v2'],
         'already_fixed_on': [],
         'flags_to_set': {
             'v1-status': 'fixed'
         },
         'uplift_status': {
             'abcd123': {
                 'success': {'v1': '321dcba'},
                 'failure': ['v2']
             }
         }
     }
     with patch('gaia_uplift.bzapi.update_bug') as update_bug, \
          patch('gaia_uplift.git.sort_commits') as sort_commits, \
          patch('gaia_uplift.bzapi.fetch_complete_bug') as fetch_bug, \
          patch('gaia_uplift.reporting.merge_script') as merge_script:
         bug_data = {
             'comments': [],
             'assigned_to': {'name': 'testuser'}
         }
         fetch_bug.return_value = bug_data
         merge_script.return_value = 'a_merge_script'
         msg = subject.generate_ugly_bug_msg(bug)
         self.assertIsNotNone(msg)
         subject.ugly_bug_comment(None, '123456', bug)
         expected_flags = subject.make_needinfo(bug_data)
         update_bug.assert_called_once_with(
             '123456', comment=msg, values=bug['flags_to_set'], flags=expected_flags)
示例#2
0
 def test_failure(self):
     bug = {
         'commits': ['abcd123'],
         'needed_on': ['v1'],
         'already_fixed_on': [],
         'flags_to_set': {
         },
         'uplift_status': {
             'abcd123': {
                 'success': {},
                 'failure': ['v1']
             }
         }
     }
     with patch('gaia_uplift.bzapi.update_bug') as update_bug, \
          patch('gaia_uplift.git.sort_commits') as sort_commits, \
          patch('gaia_uplift.bzapi.fetch_complete_bug') as fetch_bug, \
          patch('gaia_uplift.reporting.merge_script') as merge_script:
         sort_commits.return_value = ['abcd123']
         merge_script.return_value = 'a_merge_script'
         bug_data = {
             'comments': [],
             'assigned_to': {'name': 'testuser'}
         }
         fetch_bug.return_value = bug_data
         expected_flags = subject.make_needinfo(bug_data)
         msg = subject.generate_bad_bug_msg(None, bug)
         self.assertIsNotNone(msg)
         update_bug.side_effect = Exception
         with self.assertRaises(subject.FailedToComment):
             subject.bad_bug_comment(None, '123456', bug)
         update_bug.assert_called_once_with(
             '123456', comment=msg, values=bug['flags_to_set'], flags=expected_flags)
示例#3
0
 def test_assingee(self):
     bug_data = {
         'assigned_to': {
             'name': 'testuser'
         }
     }
     expected = [{
         'name': 'needinfo',
         'requestee': {
             'name': 'testuser'
         },
         'status': '?',
         'type_id': '800'
     }]
     actual = subject.make_needinfo(bug_data)
     self.assertEqual(expected, actual)
示例#4
0
 def test_fallback(self):
     bug_data = {
         'assigned_to': {
             'name': '*****@*****.**'
         },
         'creator': {
             'name': 'testuser'
         }
     }
     expected = [{
         'name': 'needinfo',
         'requestee': {
             'name': 'testuser'
         },
         'status': '?',
         'type_id': '800'
     }]
     actual = subject.make_needinfo(bug_data)
     self.assertEqual(expected, actual)