diff --git a/tests/models/__init__.py b/tests/models/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/models/github/__init__.py b/tests/models/github/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/models/github/test_commit.py b/tests/models/github/test_commit.py new file mode 100644 index 0000000..38288b4 --- /dev/null +++ b/tests/models/github/test_commit.py @@ -0,0 +1,13 @@ +import unittest + +from bot.models.github.commit import Commit + + +class CommitTest(unittest.TestCase): + + def test_should_create_commit(self): + commit = Commit(message="Hello, this is unittest", + sha="0009829KJHB998SB", + link="www.unittest.com") + self.assertEqual(str(commit), + "") diff --git a/tests/models/github/test_event_type.py b/tests/models/github/test_event_type.py new file mode 100644 index 0000000..896052e --- /dev/null +++ b/tests/models/github/test_event_type.py @@ -0,0 +1,36 @@ +# import unittest +# from enum import Enum + +# from bot.models.github.event_type import EventType, convert_keywords_to_events + +# class ExampleEnum(Enum): +# BRANCH_CREATED = ("bc", "A Branch was created") +# BRANCH_DELETED = ("bd", "A Branch was deleted") +# TAG_CREATED = ("tc", "A Tag was created") +# TAG_DELETED = ("td", "A Tag was deleted") +# PULL_CLOSED = ("prc", "A Pull Request was closed") +# PULL_MERGED = ("prm", "A Pull Request was merged") +# PULL_OPENED = ("pro", "A Pull Request was opened") +# PULL_READY = ("prr", "A Pull Request is ready") +# ISSUE_OPENED = ("iso", "An Issue was opened") +# ISSUE_CLOSED = ("isc", "An Issue was closed") +# REVIEW = ("rv", "A Review was given on a Pull Request") +# REVIEW_COMMENT = ("rc", "A Comment was added to a Review") +# COMMIT_COMMENT = ("cc", "A Comment was made on a Commit") +# ISSUE_COMMENT = ("ic", "A Comment was made on an Issue") +# FORK = ("fk", "Repository was forked by a user") +# PUSH = ("p", "One or more Commits were pushed") +# RELEASE = ("rl", "A new release was published") +# STAR_ADDED = ("sa", "A star was added to repository") +# STAR_REMOVED = ("sr", "A star was removed from repository") + +# class TestEventType(unittest.TestCase): + +# def test_convert_keywords_to_events_all_in_non_single_list(self): +# list1 = [] +# list2 = [] +# for x in set(ExampleEnum): +# list1.append(x) +# for x in convert_keywords_to_events(["*"]): +# list2.append(x) +# self.assertEqual(list1, list2) diff --git a/tests/models/github/test_issue.py b/tests/models/github/test_issue.py new file mode 100644 index 0000000..ba1bd20 --- /dev/null +++ b/tests/models/github/test_issue.py @@ -0,0 +1,13 @@ +import unittest + +from bot.models.github.issue import Issue + + +class IssueTest(unittest.TestCase): + + def test_should_create_issue(self): + issue = Issue(title="unittest issue", + number="22", + link="www.unittestIsue.com") + self.assertEqual(str(issue), + "") diff --git a/tests/models/github/test_pull_request.py b/tests/models/github/test_pull_request.py new file mode 100644 index 0000000..5d2d162 --- /dev/null +++ b/tests/models/github/test_pull_request.py @@ -0,0 +1,12 @@ +import unittest + +from bot.models.github.pull_request import PullRequest + + +class PullRequestTest(unittest.TestCase): + + def test_should_create_pull_request(self): + pr = PullRequest("hey, this is Unittest pr", "44", + "www.unittestpr.com") + self.assertEqual(str(pr), + "") diff --git a/tests/models/github/test_ref.py b/tests/models/github/test_ref.py new file mode 100644 index 0000000..ef0d367 --- /dev/null +++ b/tests/models/github/test_ref.py @@ -0,0 +1,10 @@ +import unittest + +from bot.models.github.ref import Ref + + +class RefTest(unittest.TestCase): + + def test_should_create_Ref(self): + ref = Ref(name="hey, this is unittest ref", ref_type="branch") + self.assertEqual(str(ref), "hey, this is unittest ref") diff --git a/tests/models/test_link.py b/tests/models/test_link.py new file mode 100644 index 0000000..a4244a2 --- /dev/null +++ b/tests/models/test_link.py @@ -0,0 +1,18 @@ +import unittest + +from bot.models.link import Link + + +class LinkTest(unittest.TestCase): + + def test_should_make_link(self): + link = Link(url="www.unittest.com", text="unittest") + self.assertEqual(str(link), "") + + def test_should_make_link_without_url(self): + link = Link(text="unittest1") + self.assertEqual(str(link), "") + + def test_should_make_link_without_text(self): + link = Link(text="www.unittest1.com") + self.assertEqual(str(link), "") diff --git a/tests/models/test_slack.py b/tests/models/test_slack.py new file mode 100644 index 0000000..826bf42 --- /dev/null +++ b/tests/models/test_slack.py @@ -0,0 +1,27 @@ +import unittest + +from bot.models.github.event_type import EventType +from bot.models.slack import Channel + + +class ChannelTest(unittest.TestCase): + + def test_should_make_channel_str(self): + channel = Channel("unittest_channel", [ + EventType.BRANCH_CREATED, EventType.COMMIT_COMMENT, EventType.FORK + ]) + self.assertEqual(str(channel), "unittest_channel") + + def test_is_subscribed_to_false(self): + channel = Channel("unittest_channel", [ + EventType.BRANCH_CREATED, EventType.COMMIT_COMMENT, EventType.FORK + ]) + self.assertEqual( + False, channel.is_subscribed_to(event=EventType.ISSUE_CLOSED)) + + def test_is_subscribed_to_true(self): + channel = Channel("unittest_channel", [ + EventType.BRANCH_CREATED, EventType.COMMIT_COMMENT, EventType.FORK + ]) + self.assertEqual(True, + channel.is_subscribed_to(EventType.BRANCH_CREATED))