This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
actioner/tests/test_utils/test_github.py

36 lines
1 KiB
Python
Raw Permalink Normal View History

from collections import namedtuple
from actioner.utils.github import get_existing_task, get_issue_link
from tests import BaseTestCase
2019-02-22 22:36:17 +00:00
FakeIssue = namedtuple("FakeIssue", ["number", "html_url", "title"])
class IssueLinkTestCase(BaseTestCase):
def setUp(self):
super().setUp()
2019-02-22 22:36:17 +00:00
self.issue = FakeIssue(123, "https://github.com/repo/thing", "issue title")
def test_creates_link(self):
2019-02-22 22:36:17 +00:00
self.assertEqual(
get_issue_link(self.issue), "[#123](https://github.com/repo/thing)"
)
class ExistingTaskTestCase(BaseTestCase):
def setUp(self):
super().setUp()
self.tasks = {
2019-02-22 22:36:17 +00:00
123: "[#1](url): title",
456: "[#2](url/2): title 2",
789: "[#3](url/3): title 3",
}
def test_finds_existing_repos(self):
self.assertEqual(
2019-02-22 22:36:17 +00:00
get_existing_task(self.tasks, FakeIssue(1, "url", "title")), 123
)
def test_not_existing_repo(self):
2019-02-22 22:36:17 +00:00
self.assertIsNone(get_existing_task(self.tasks, FakeIssue(123, "url", "title")))