Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLorenzo committed Feb 26, 2019
1 parent de0bf14 commit 4fdb421
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 12 deletions.
14 changes: 7 additions & 7 deletions scriptworker/test/test_cot_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -2251,15 +2251,15 @@ async def test_trace_back_to_tree_diff_repo(chain, decision_link,
await cotverify.trace_back_to_tree(chain)


# @pytest.mark.parametrize('source_url, raises', (
# ('https://github.com/mozilla-mobile/focus-android', False),
# ('https://github.com/JohanLorenzo/focus-android', True),
# ('https://github.com/mitchhentges/focus-android', True),
# ('https://github.com/MihaiTabara/focus-android', True),
# ))
@pytest.mark.parametrize('source_url, raises', (
('https://github.com/mozilla-mobile/focus-android', False),
('https://github.com/JohanLorenzo/focus-android', True),
('https://github.com/mitchhentges/focus-android', True),
('https://github.com/MihaiTabara/focus-android', True),
))
@pytest.mark.asyncio
async def test_trace_back_to_tree_mobile_staging_repos_dont_access_restricted_scopes(
mobile_chain, mobile_github_release_link, mobile_build_link
mobile_chain, mobile_github_release_link, mobile_build_link, source_url, raises
):
(source_url, raises) = ('https://github.com/mozilla-mobile/focus-android', False)
mobile_github_release_link.task['metadata']['source'] = source_url
Expand Down
24 changes: 19 additions & 5 deletions scriptworker/test/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def context():
def github_repository(mocker):
github_repository_mock = MagicMock()
github_repository_mock.html_url = 'https://github.com/some-user/some-repo/'
github_repository_mock.tags.return_value = [SimpleNamespace(name='v1.0.0', commit='hashforv1000')]
github_repository_mock.tags.return_value = [
SimpleNamespace(name='v1.0.0', commit=SimpleNamespace(sha='hashforv100')),
]
github_instance_mock = MagicMock()
github_instance_mock.repository.return_value = github_repository_mock
mocker.patch.object(github, 'GitHub', return_value=github_instance_mock)
Expand Down Expand Up @@ -62,15 +64,27 @@ def test_get_release(github_repository):


@pytest.mark.parametrize('tags, raises, expected', ((
[SimpleNamespace(name='some-tag', commit='somecommit')],
[SimpleNamespace(
name='some-tag',
commit=SimpleNamespace(sha='somecommit'),
)],
False,
'somecommit',
), (
[SimpleNamespace(name='another-tag', commit='anothercommit'), SimpleNamespace(name='some-tag', commit='somecommit')],
[SimpleNamespace(
name='another-tag',
commit=SimpleNamespace(sha='anothercommit'),
), SimpleNamespace(
name='some-tag',
commit=SimpleNamespace(sha='somecommit'),
)],
False,
'somecommit',
), (
[SimpleNamespace(name='another-tag', commit='anothercommit')],
[SimpleNamespace(
name='another-tag',
commit=SimpleNamespace(sha='anothercommit'),
)],
True,
None
), (
Expand Down Expand Up @@ -123,7 +137,7 @@ def test_get_tag_hash(github_repository, tags, raises, expected):
True,
), (
'v1.0.0',
'https://github.com/some-user/some-repo/branch_commits/hashforv1000',
'https://github.com/some-user/some-repo/branch_commits/hashforv100',
'''
Expand Down
13 changes: 13 additions & 0 deletions scriptworker/test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,19 @@ def test_get_loggable_url(url, expected):
assert utils.get_loggable_url(url) == expected


@pytest.mark.parametrize('url, expected', ((
'https://foo/bar', ['bar']
), (
'https://foo/bar/baz', ['bar', 'baz']
), (
'https://foo/bar/baz?param1=value', ['bar', 'baz']
), (
'https://foo/bar/baz?param1=value1&param2=value2', ['bar', 'baz']
)))
def test_get_parts_of_url_path(url, expected):
assert utils.get_parts_of_url_path(url) == expected


# match_url_path_callback {{{1
@pytest.mark.parametrize("path", (
"/mozilla-central", "/mozilla-central/foo/bar", "/mozilla-central/"
Expand Down

0 comments on commit 4fdb421

Please sign in to comment.