Skip to content

Commit

Permalink
🔴 having a user mismatch between user and url does not cause an error
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrecamilleri committed Nov 15, 2024
1 parent 5e36d7b commit 3765e2b
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
14 changes: 0 additions & 14 deletions frictionless/portals/github/__spec__/test_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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")
Expand Down
33 changes: 33 additions & 0 deletions frictionless/portals/github/__spec__/test_plugin.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 3765e2b

Please sign in to comment.