diff --git a/scriptworker/test/test_cot_verify.py b/scriptworker/test/test_cot_verify.py index 54eec386..cdabb2a8 100644 --- a/scriptworker/test/test_cot_verify.py +++ b/scriptworker/test/test_cot_verify.py @@ -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 diff --git a/scriptworker/test/test_github.py b/scriptworker/test/test_github.py index 55982ae3..1ab340c6 100644 --- a/scriptworker/test/test_github.py +++ b/scriptworker/test/test_github.py @@ -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) @@ -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 ), ( @@ -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', ''' diff --git a/scriptworker/test/test_utils.py b/scriptworker/test/test_utils.py index 3e428a16..13b96754 100644 --- a/scriptworker/test/test_utils.py +++ b/scriptworker/test/test_utils.py @@ -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¶m2=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/"