def test_latest_release(): mocked_releases = [ Release(title='0.0.1', body='', tag_name='', url='', created_at='', tarball_url='', git_tag=GitTag(name='0.0.1', commit_sha='123')), Release(title='0.0.2', body='', tag_name='', url='', created_at='', tarball_url='', git_tag=GitTag(name='0.0.2', commit_sha='123')) ] git = flexmock(Git) c = flexmock(configuration) c.project = flexmock(get_releases=lambda: mocked_releases) github = Github(c, git) obtained_release = github.latest_release() assert obtained_release == '0.0.2' mocked_releases = [] c.project = flexmock(get_releases=lambda: mocked_releases) github = Github(c, git) obtained_release = github.latest_release() assert obtained_release == '0.0.0'
def _release_from_git_tag(git_tag: GitTag) -> Release: return Release( title=git_tag.name, body="", tag_name=git_tag.name, url="", created_at="", tarball_url="", git_tag=git_tag, )
def _release_from_github_object(raw_release: GithubRelease) -> Release: """ Get ogr.abstract.Release object from github.GithubRelease :param raw_release: GithubRelease, object from Github API https://developer.github.com/v3/repos/releases/ :return: Release, example(type, value): title: str, "0.1.0" body: str, "Description of the release" tag_name: str, "v1.0.0" url: str, "https://api.github.com/repos/octocat/Hello-World/releases/1" created_at: datetime.datetime, 2018-09-19 12:56:26 tarball_url: str, "https://api.github.com/repos/octocat/Hello-World/tarball/v1.0.0" """ return Release( title=raw_release.title, body=raw_release.body, tag_name=raw_release.tag_name, url=raw_release.url, created_at=raw_release.created_at, tarball_url=raw_release.tarball_url, )
) assert status table = status.get_builds(number_of_builds) assert table assert len(table.keys()) == number_of_builds assert table == expected_results @pytest.mark.parametrize( "expected_releases", ( ([ Release( "Release title1", "beer1", "0.0.1", "www.packit.dev", "23-5-2018", "www.packit.dev/tarball1", ), Release( "Release title2", "beer2", "0.0.2", "www.packit.dev", "23-6-2018", "www.packit.dev/tarball2", ), Release( "Release title3", "beer3", "0.0.3",