From ef8c4f04e56ac00c5bcf881b63d09313dc3a2214 Mon Sep 17 00:00:00 2001 From: Matheus Felipe <50463866+matheusfelipeog@users.noreply.github.com> Date: Wed, 12 Jan 2022 01:26:39 -0300 Subject: [PATCH] Create basic test to get host from link --- scripts/tests/test_validate_links.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/tests/test_validate_links.py b/scripts/tests/test_validate_links.py index c655f4af..c5a3fd4b 100644 --- a/scripts/tests/test_validate_links.py +++ b/scripts/tests/test_validate_links.py @@ -3,6 +3,7 @@ import unittest from validate.links import find_links_in_text +from validate.links import get_host_from_link class TestValidateLinks(unittest.TestCase): @@ -42,3 +43,25 @@ class TestValidateLinks(unittest.TestCase): find_links_in_text() find_links_in_text(1) find_links_in_text(True) + + def test_get_host_from_link(self): + links = [ + 'example.com', + 'https://example.com', + 'https://www.example.com', + 'https://www.example.com.br', + 'https://www.example.com/route', + 'https://www.example.com?p=1&q=2', + 'https://www.example.com#anchor' + ] + + for link in links: + host = get_host_from_link(link) + + with self.subTest(): + self.assertIsInstance(host, str) + + self.assertNotIn('://', host) + self.assertNotIn('/', host) + self.assertNotIn('?', host) + self.assertNotIn('#', host)