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
bf4dfcd3
Unverified
Commit
bf4dfcd3
authored
Jan 11, 2022
by
Matheus Felipe
Browse files
Create basic test to find_link_in_text function
parent
80ba7262
Changes
1
Show whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_links.py
View file @
bf4dfcd3
...
...
@@ -2,6 +2,45 @@
import
unittest
from
validate.links
import
find_links_in_text
class
TestValidateLinks
(
unittest
.
TestCase
):
...
def
setUp
(
self
):
self
.
text
=
"""
# this is valid
http://example.com?param1=1¶m2=2#anchor
https://www.example.com?param1=1¶m2=2#anchor
https://www.example.com.br
https://www.example.com.gov.br
[Example](https://www.example.com?param1=1¶m2=2#anchor)
lorem ipsum https://www.example.com?param1=1¶m2=2#anchor
https://www.example.com?param1=1¶m2=2#anchor lorem ipsum
# this not is valid
example.com
https:example.com
https:/example.com
https//example.com
https//.com
"""
def
test_find_link_in_text
(
self
):
links
=
find_links_in_text
(
self
.
text
)
self
.
assertIsInstance
(
links
,
list
)
self
.
assertEqual
(
len
(
links
),
7
)
for
link
in
links
:
with
self
.
subTest
():
self
.
assertIsInstance
(
link
,
str
)
def
test_find_link_in_text_with_invalid_argument
(
self
):
with
self
.
assertRaises
(
TypeError
):
find_links_in_text
()
find_links_in_text
(
1
)
find_links_in_text
(
True
)
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