Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
public-apis
Commits
ef8c4f04
Unverified
Commit
ef8c4f04
authored
Jan 12, 2022
by
Matheus Felipe
Browse files
Create basic test to get host from link
parent
8650f7f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_links.py
View file @
ef8c4f04
...
...
@@ -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
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment