2022-06-03 22:41:13 +02:00
|
|
|
from wulkabot.cogs import github
|
|
|
|
|
|
|
|
|
|
|
|
def test_parse_repo():
|
2022-06-06 00:09:42 +02:00
|
|
|
assert github.parse_repo("owner/repo") == ("owner", "repo")
|
|
|
|
assert github.parse_repo("repo", default_owner="owner") == ("owner", "repo")
|
|
|
|
assert github.parse_repo("repo") is None
|
2022-06-03 22:41:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_parse_issue():
|
2022-06-07 20:53:21 +02:00
|
|
|
assert github.parse_issue("owner/repo#1") == (("owner", "repo"), 1)
|
2022-06-06 00:09:42 +02:00
|
|
|
assert github.parse_issue("owner/repo#0") is None
|
|
|
|
assert github.parse_issue("#1", default_owner="owner", default_repo="repo") == (
|
|
|
|
("owner", "repo"),
|
2022-06-03 22:41:13 +02:00
|
|
|
1,
|
|
|
|
)
|
2022-06-06 00:09:42 +02:00
|
|
|
assert github.parse_issue("repo#1", default_owner="owner") == (("owner", "repo"), 1)
|
|
|
|
assert github.parse_issue("#1", default_owner="owner") is None
|
|
|
|
assert github.parse_issue("#1", default_repo="repo") is None
|
|
|
|
assert github.parse_issue("repo#1", default_repo="repo") is None
|
|
|
|
assert github.parse_issue("repo#1") is None
|
|
|
|
assert github.parse_issue("#1") is None
|
|
|
|
assert github.parse_issue("") is None
|
2022-06-03 22:41:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
def test_find_repo_in_channel_topic():
|
2022-06-06 00:09:42 +02:00
|
|
|
assert github.find_repo_in_channel_topic("https://github.com/owner/repo") == ("owner", "repo")
|
|
|
|
assert github.find_repo_in_channel_topic("https://github.com/owner") is None
|
2022-06-03 22:41:13 +02:00
|
|
|
assert github.find_repo_in_channel_topic("https://github.com/") is None
|
2022-06-06 00:09:42 +02:00
|
|
|
assert github.find_repo_in_channel_topic("owner/repo") is None
|
|
|
|
assert github.find_repo_in_channel_topic("") is None
|