def test_get_last_version(skip_tags, expected_result): class FakeCommit: def __init__(self, com_date): self.committed_date = com_date class FakeTagObject: def __init__(self, tag_date): self.tagged_date = tag_date class FakeTag: def __init__(self, name, sha, date, is_tag_object): self.name = name self.tag = FakeTagObject(date) if is_tag_object: self.commit = TagObject(Repo(), sha) else: self.commit = FakeCommit(date) mock.patch("semantic_release.vcs_helpers.check_repo") git.repo.base.Repo.tags = mock.PropertyMock(return_value=[ FakeTag("v0.1.0", "aaaaaaaaaaaaaaaaaaaa", 1, True), FakeTag("v2.0.0", "dddddddddddddddddddd", 4, True), FakeTag("badly_formatted", "eeeeeeeeeeeeeeeeeeee", 5, False), FakeTag("v1.1.0", "cccccccccccccccccccc", 3, True), FakeTag("v1.0.0", "bbbbbbbbbbbbbbbbbbbb", 2, False), ]) assert expected_result == get_last_version(skip_tags)
def test_get_last_version(skip_tags, expected_result): class FakeCommit: def __init__(self, com_date): self.committed_date = com_date class FakeTagObject: def __init__(self, tag_date): self.tagged_date = tag_date class FakeTag: def __init__(self, name, sha, date, is_tag_object): self.name = name self.tag = FakeTagObject(date) if is_tag_object: self.commit = TagObject(Repo(), sha) else: self.commit = FakeCommit(date) mock.patch('semantic_release.vcs_helpers.check_repo') git.repo.base.Repo.tags = mock.PropertyMock(return_value=[ FakeTag('v0.1.0', 'aaaaaaaaaaaaaaaaaaaa', 1, True), FakeTag('v2.0.0', 'dddddddddddddddddddd', 4, True), FakeTag('badly_formatted', 'eeeeeeeeeeeeeeeeeeee', 5, False), FakeTag('v1.1.0', 'cccccccccccccccccccc', 3, True), FakeTag('v1.0.0', 'bbbbbbbbbbbbbbbbbbbb', 2, False), ]) assert expected_result == get_last_version(skip_tags)