Skip to content

Commit

Permalink
test: Add unittests for convert_links method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnesium12 committed Sep 9, 2022
1 parent 2b5397a commit b32adb0
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/github/test_github_parsers.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import unittest
from typing import Any

from bot.github.github_parsers import GitHubPayloadParser, find_ref
from bot.github.github_parsers import GitHubPayloadParser, convert_links, find_ref

from ..utils.deserializers import github_payload_deserializer
from ..utils.load import load_test_data
Expand Down Expand Up @@ -45,6 +45,29 @@ def test_find_ref(self):
find_ref("refs/heads/username/branch-name"))
self.assertEqual("branch-name", find_ref("branch-name"))

def test_convert_links(self):
self.assertEqual(
"Some comment text <www.xyz.com|Link text> text",
convert_links("Some comment text [Link text](www.xyz.com) text"))
self.assertEqual(
"Some comment text <www.xyz.com/abcd|Link text> text",
convert_links(
"Some comment text [Link text](www.xyz.com/abcd) text"))
self.assertEqual(
"Some comment text <www.xyz.com?q=1234|Link text> text",
convert_links(
"Some comment text [Link text](www.xyz.com?q=1234) text"))
self.assertEqual(
"Some comment text <www.xyz.com|Link text> text <https://www.qwerty.com/|Link text 2nd>",
convert_links(
"Some comment text [Link text](www.xyz.com) text [Link text 2nd](https://www.qwerty.com/)"
))
self.assertEqual(
"Some comment text [Link text <www.example.link.com|Link inside link text>](www.xyz.com) text",
convert_links(
"Some comment text [Link text [Link inside link text](www.example.link.com)](www.xyz.com) text"
))


if __name__ == '__main__':
unittest.main()

0 comments on commit b32adb0

Please sign in to comment.