def test_create_release_strips_whitespaces(self):
        proj, repo = _create_mocks("0.1.0")
        step = MagicMock()

        cycle = ReleaseCycle(proj, repo, [step])
        cycle.create_release("\t\n 0.3.4  ")

        self.assertEqual(1, step.execute.call_count)
        step.execute.assert_called_once_with(proj, repo, "0.3.4")
    def test_step_executed(self):
        proj, repo = _create_mocks("0.1.0")
        step = MagicMock()

        cycle = ReleaseCycle(proj, repo, [step])
        cycle.create_release("0.1.1")

        self.assertEqual(1, step.execute.call_count)
        step.execute.assert_called_once_with(proj, repo, "0.1.1")
 def test_project_and_repository_from_path(self, mock):
     with patch.object(git.Repo, "__init__", lambda p0, p1: None), \
             patch.object(CMakeProject, "__init__", lambda p0, p1: None):
         cycle = ReleaseCycle.from_path("/tmp/cmake_project", [MagicMock()])
         mock.assert_called_once_with("/tmp/cmake_project/CMakeLists.txt")
         self.assertIsInstance(cycle.project, CMakeProject)
         self.assertIsInstance(cycle.repository, git.Repo)
         self.assertEqual(1, cycle.number_of_steps())
Exemple #4
0
def main():
    args = parse_args()
    new_version = args.release_version
    cycle = ReleaseCycle.from_path(
        args.path[0],
        [PreconditionStep(),
         UpdateVersionStep(),
         CommitAndTagStep()])
    cycle.create_release(new_version)
    def test_steps_executed_in_order(self):
        proj, repo = _create_mocks("6.6.7")
        steps = [MagicMock(), MagicMock(), MagicMock()]

        cycle = ReleaseCycle(proj, repo, steps)

        expected_args = (proj, repo, "6.7.8")
        manager = Mock()
        (manager.step_0, manager.step_1, manager.step_2) = (steps[0], steps[1],
                                                            steps[2])

        cycle.create_release("6.7.8")

        expected_calls = [
            call.step_0.execute(*expected_args),
            call.step_1.execute(*expected_args),
            call.step_2.execute(*expected_args)
        ]
        self.assertEqual(expected_calls, manager.mock_calls)
Exemple #6
0
def main():
    args = parse_args()
    new_version = args.release_version

    try:
        cycle = ReleaseCycle.from_path(args.path, [
            PreconditionStep(),
            UpdateVersionStep(),
            CommitAndTagStep(args.message)
        ])
        cycle.create_release(new_version)
    except ReleaseException as ex:
        print(f"ERROR: {ex}")
        sys.exit(1)
 def test_from_path_throws_if_no_project_file(self, mock):
     with patch.object(git.Repo, "__init__", lambda p0, p1: None):
         with self.assertRaises(UnsupportedProjectException):
             ReleaseCycle.from_path("/tmp/cmake_project", [MagicMock()])
     mock.assert_called_once_with("/tmp/cmake_project/CMakeLists.txt")