示例#1
0
 def test_apply_transformations_with_changes_and_callback(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch(
             'gordian.transformations.Transformation'
     ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = True
         callback_mock = MagicMock()
         args = TestGordian.Args()
         args.target_branch = 'target_branch'
         apply_transformations(args, [TransformationMockClass],
                               callback_mock)
         pull_request = RepoMock.return_value.create_pr.return_value
         RepoMock.assert_has_calls(
             [call().bump_version(False),
              call().bump_version(False)],
             any_order=True)
         RepoMock.assert_has_calls([
             call().create_pr('test', '', 'target_branch', ANY),
             call().create_pr('test', '', 'target_branch', ANY)
         ],
                                   any_order=True)
         callback_mock.assert_has_calls([
             call('testOrg/TestService1', pull_request),
             call('testOrg/TestService2', pull_request)
         ])
示例#2
0
 def test_apply_transformations_with_changes_dry_run(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch('gordian.transformations.Transformation', ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = True
         apply_transformations(TestGordian.Args(dry_run=True), [TransformationMockClass])
         RepoMock.assert_has_calls([call().bump_version(False, False, False, True), call().bump_version(False, False, False, True)], any_order=True)
         self.assertNotIn(call().repo.create_pull('test', '', 'master', ANY), RepoMock.mock_calls)
示例#3
0
def main():
    parser = get_basic_parser()
    parser.add_argument('-e',
                        '--environments',
                        required=False,
                        dest='environments',
                        default='prd-.*',
                        help='Environments to update.')
    args = parser.parse_args(sys.argv[1:])
    apply_transformations(args, [NullTest])
示例#4
0
 def test_apply_transformations_without_changes(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch(
             'gordian.transformations.Transformation'
     ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = False
         apply_transformations(TestGordian.Args(),
                               [TransformationMockClass])
         RepoMock.assert_has_calls([
             call('testOrg/TestService1',
                  github_api_url=None,
                  branch='test'),
             call(
                 'testOrg/TestService2', github_api_url=None, branch='test')
         ],
                                   any_order=True)
示例#5
0
 def test_apply_transformations_with_changes(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch(
             'gordian.transformations.Transformation'
     ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = True
         apply_transformations(TestGordian.Args(),
                               [TransformationMockClass])
         RepoMock.assert_has_calls(
             [call().bump_version(False),
              call().bump_version(False)],
             any_order=True)
         RepoMock.assert_has_calls([
             call().create_pr('test', '', 'master', ANY),
             call().create_pr('test', '', 'master', ANY)
         ],
                                   any_order=True)
示例#6
0
 def test_apply_transformations_with_changes_custom_description(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch(
             'gordian.transformations.Transformation',
     ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = True
         gordian_args = TestGordian.Args()
         description = 'Custom file for pr description\n'
         gordian_args.description_file = './tests/fixtures/pr_description'
         apply_transformations(gordian_args, [TransformationMockClass])
         RepoMock.assert_has_calls(
             [call().bump_version(False),
              call().bump_version(False)],
             any_order=True)
         RepoMock.assert_has_calls([
             call().create_pr('test', description, 'master', ANY),
             call().create_pr('test', description, 'master', ANY)
         ],
                                   any_order=True)
示例#7
0
 def test_apply_transformations_with_changes_default_labels(self):
     with patch('gordian.gordian.Repo') as RepoMock, patch(
             'gordian.transformations.Transformation',
     ) as TransformationMockClass:
         instance = RepoMock.return_value
         instance.dirty = True
         gordian_args = TestGordian.Args()
         gordian_args.pr_labels = []
         apply_transformations(gordian_args, [TransformationMockClass])
         RepoMock.assert_has_calls(
             [call().bump_version(False),
              call().bump_version(False)],
             any_order=True)
         RepoMock.assert_has_calls([
             call().create_pr('test', '', 'master', ANY),
             call().create_pr('test', '', 'master', ANY)
         ],
                                   any_order=True)
         self.assertNotIn(call()._repo.create_pull().set_labels(ANY),
                          RepoMock.mock_calls)