def test_SingleBuildWithCrossVerify(self): helper = TestHelper(self, workspace='ws', env={ 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': '3', }) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': None, 'result': 'SUCCESS' } ], 'gerrit_info': { 'change': 1234, 'patchset': 5 } }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': 'http://my_build', 'message': None }) helper.assertCommandInvoked(['ssh', '-p', '29418', '*****@*****.**', 'gerrit', 'review', '1234,5', '-m', '"Cross-verify with http://gerrit (patch set 3) finished\n\nhttp://my_build: SUCCESS"'])
def test_NoBuild(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': None, 'message': None })
def test_SingleBuildWithCrossVerify(self): helper = TestHelper(self, env={ 'GERRIT_CHANGE_URL': 'http://gerrit', 'GERRIT_PATCHSET_NUMBER': '3', }) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': None, 'result': 'SUCCESS' }], 'gerrit_info': { 'change': 1234, 'patchset': 5 } }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': 'http://my_build', 'message': None}) helper.assertCommandInvoked([ 'ssh', '-p', '29418', '*****@*****.**', 'gerrit', 'review', '1234,5', '-m', '"Cross-verify with http://gerrit (patch set 3) finished\n\nhttp://my_build: SUCCESS"' ])
def test_SingleBuildWithDescription(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' } ] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': 'http://my_build (cross-verify)', 'message': None })
def test_SingleBuildWithoutUrl(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'title': 'My title', 'url': None, 'desc': None, 'result': 'SUCCESS' } ] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': None, 'message': None })
def test_FailedSingleBuild(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': None, 'result': 'FAILURE', 'reason': 'Failure reason' } ] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': 'http://my_build', 'message': 'Failure reason' })
def test_NoBuild(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, { 'url': None, 'message': None })
def test_SingleBuild(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': None, 'result': 'SUCCESS' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': 'http://my_build', 'message': None})
def test_TwoBuildsWithoutUrl(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' }, { 'title': 'My title', 'url': None, 'desc': None, 'result': 'SUCCESS' } ] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': None, 'message': 'http://my_build (cross-verify): SUCCESS\nMy title: SUCCESS' })
def test_TwoBuildsWithFailure(self): helper = TestHelper(self, workspace='ws') factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' }, { 'url': 'http://my_build2', 'desc': None, 'result': 'FAILURE', 'reason': 'Failure reason' } ] }) do_post_build(factory, 'actions.json', 'message.json') helper.assertOutputJsonFile('ws/build/message.json', { 'url': None, 'message': 'http://my_build (cross-verify): SUCCESS\nhttp://my_build2: FAILURE <<<\nFailure reason\n>>>' })
def test_FailedSingleBuildWithoutUrl(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'title': 'My title', 'url': None, 'desc': None, 'result': 'FAILURE', 'reason': 'Failure reason' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': None, 'message': 'Failure reason'})
def test_SingleBuildWithDescription(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' } ] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, { 'url': 'http://my_build (cross-verify)', 'message': None })
def test_SingleBuildWithoutUrl(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'title': 'My title', 'url': None, 'desc': None, 'result': 'SUCCESS' } ] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, { 'url': None, 'message': None })
def test_FailedSingleBuild(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': None, 'result': 'FAILURE', 'reason': 'Failure reason' } ] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, { 'url': 'http://my_build', 'message': 'Failure reason' })
def test_TwoBuilds(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file( 'actions.json', { 'builds': [{ 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' }, { 'url': 'http://my_build2', 'desc': None, 'result': 'SUCCESS' }] }) result = do_post_build(factory, 'actions.json') self.assertEqual( result, { 'url': None, 'message': 'http://my_build (cross-verify): SUCCESS\nhttp://my_build2: SUCCESS' })
def test_TwoBuildsWithoutUrl(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', { 'builds': [ { 'url': 'http://my_build', 'desc': 'cross-verify', 'result': 'SUCCESS' }, { 'title': 'My title', 'url': None, 'desc': None, 'result': 'SUCCESS' } ] }) result = do_post_build(factory, 'actions.json') self.assertEqual(result, { 'url': None, 'message': 'http://my_build (cross-verify): SUCCESS\nMy title: SUCCESS' })
def test_NoBuild(self): helper = TestHelper(self) factory = helper.factory helper.add_input_json_file('actions.json', {'builds': []}) result = do_post_build(factory, 'actions.json') self.assertEqual(result, {'url': None, 'message': None})