From 3765e2b1d713435ee0ac92c91ef4c7f9fcc5c2d6 Mon Sep 17 00:00:00 2001 From: Pierre Camilleri <22995923+pierrecamilleri@users.noreply.github.com> Date: Fri, 15 Nov 2024 17:05:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=B4=20having=20a=20user=20mismatch=20b?= =?UTF-8?q?etween=20user=20and=20url=20does=20not=20cause=20an=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../portals/github/__spec__/test_adapter.py | 14 -------- .../portals/github/__spec__/test_plugin.py | 33 +++++++++++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) create mode 100644 frictionless/portals/github/__spec__/test_plugin.py diff --git a/frictionless/portals/github/__spec__/test_adapter.py b/frictionless/portals/github/__spec__/test_adapter.py index 9ed3784947..70931ef5ff 100644 --- a/frictionless/portals/github/__spec__/test_adapter.py +++ b/frictionless/portals/github/__spec__/test_adapter.py @@ -4,7 +4,6 @@ import pytest from frictionless import Catalog, FrictionlessException, Package, platform, portals -from frictionless.portals.github.plugin import GithubPlugin from frictionless.resources import TableResource OUTPUT_OPTIONS_WITH_DP_YAML = { @@ -105,19 +104,6 @@ # Read -def test_github_plugin_parse_repo(): - test_cases = [ - "https://github.com/user/some-repo", - "https://github.com/user/some-repo/some-other-stuff", - ] - - plugin = GithubPlugin() - for test_case in test_cases: - adapter = plugin.create_adapter(source=test_case) - assert adapter.control.user == "user" - assert adapter.control.repo == "some-repo" - - @pytest.mark.vcr def test_github_adapter_read(options_without_dp): url = options_without_dp.pop("url") diff --git a/frictionless/portals/github/__spec__/test_plugin.py b/frictionless/portals/github/__spec__/test_plugin.py new file mode 100644 index 0000000000..e3a54c51bb --- /dev/null +++ b/frictionless/portals/github/__spec__/test_plugin.py @@ -0,0 +1,33 @@ +import pytest + +from frictionless import FrictionlessException +from frictionless.portals.github.plugin import GithubControl, GithubPlugin + + +def test_github_plugin_parse_repo(): + test_cases = [ + {"url": "https://github.com/user/some-repo"}, + {"url": "https://github.com/user/some-repo/some-other-stuff"}, + { + "url": "https://github.com/user/some-repo/some-stuff", + "control": GithubControl(user="user", repo="some-repo"), + }, + ] + + plugin = GithubPlugin() + for test_case in test_cases: + control = test_case["control"] if "control" in test_case else None + + adapter = plugin.create_adapter(source=test_case["url"], control=control) + + assert adapter.control.user == "user" + assert adapter.control.repo == "some-repo" + + +def test_github_url_control_mismatch(): + url = "https://github.com/user/some-repo" + control = GithubControl(user="wrong-user") + + plugin = GithubPlugin() + with pytest.raises(FrictionlessException): + plugin.create_adapter(source=url, control=control)