From 87a8aa5d969f38904cc7eb3cdf464407bf2cb89e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?JelNiS=C5=82aw?= Date: Mon, 6 Jun 2022 00:09:42 +0200 Subject: [PATCH] Add more tests --- tests/cogs/test_github.py | 40 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/tests/cogs/test_github.py b/tests/cogs/test_github.py index 3454ef4..c8fb0d2 100644 --- a/tests/cogs/test_github.py +++ b/tests/cogs/test_github.py @@ -2,34 +2,30 @@ from wulkabot.cogs import github def test_parse_repo(): - assert github.parse_repo("wulkanowy/sdk") == ("wulkanowy", "sdk") - assert github.parse_repo("sdk") is None - assert github.parse_repo("sdk", default_owner="wulkanowy") == ("wulkanowy", "sdk") + 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 def test_parse_issue(): + assert github.parse_issue("owner/repo#1") == (("owner", "repo", 1)) + assert github.parse_issue("owner/repo#0") is None + assert github.parse_issue("#1", default_owner="owner", default_repo="repo") == ( + ("owner", "repo"), + 1, + ) + 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 - assert github.parse_issue("#1", default_owner="wulkanowy") is None - assert github.parse_issue("#1", default_repo="wulkanowy") is None - assert github.parse_issue("#1", default_owner="wulkanowy", default_repo="wulkanowy") == ( - ("wulkanowy", "wulkanowy"), - 1, - ) - assert github.parse_issue("wulkanowy#1") is None - assert github.parse_issue("wulkanowy#1", default_owner="wulkanowy") == ( - ("wulkanowy", "wulkanowy"), - 1, - ) - assert github.parse_issue("wulkanowy#1", default_repo="wulkanowy") is None def test_find_repo_in_channel_topic(): - assert github.find_repo_in_channel_topic("") is None - assert github.find_repo_in_channel_topic("wulkanowy/wulkanowy") is None - assert github.find_repo_in_channel_topic("https://github.com/wulkanowy/wulkanowy") == ( - "wulkanowy", - "wulkanowy", - ) - assert github.find_repo_in_channel_topic("https://github.com/wulkanowy") is None + 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 assert github.find_repo_in_channel_topic("https://github.com/") is None + assert github.find_repo_in_channel_topic("owner/repo") is None + assert github.find_repo_in_channel_topic("") is None