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
8d590690
Unverified
Commit
8d590690
authored
Jan 13, 2022
by
Matheus Felipe
Browse files
Create basic test to check_duplicate_links
parent
1866c0d8
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_links.py
View file @
8d590690
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
unittest
import
unittest
from
validate.links
import
find_links_in_text
from
validate.links
import
find_links_in_text
from
validate.links
import
check_duplicate_links
from
validate.links
import
fake_user_agent
from
validate.links
import
fake_user_agent
from
validate.links
import
get_host_from_link
from
validate.links
import
get_host_from_link
from
validate.links
import
has_cloudflare_protection
from
validate.links
import
has_cloudflare_protection
...
@@ -18,6 +19,18 @@ class FakeResponse():
...
@@ -18,6 +19,18 @@ class FakeResponse():
class
TestValidateLinks
(
unittest
.
TestCase
):
class
TestValidateLinks
(
unittest
.
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
duplicate_links
=
[
'https://www.example.com'
,
'https://www.example.com'
,
'https://www.example.com'
,
'https://www.anotherexample.com'
,
]
self
.
no_duplicate_links
=
[
'https://www.firstexample.com'
,
'https://www.secondexample.com'
,
'https://www.anotherexample.com'
,
]
self
.
code_200
=
200
self
.
code_200
=
200
self
.
code_403
=
403
self
.
code_403
=
403
self
.
code_503
=
503
self
.
code_503
=
503
...
@@ -63,7 +76,26 @@ class TestValidateLinks(unittest.TestCase):
...
@@ -63,7 +76,26 @@ class TestValidateLinks(unittest.TestCase):
find_links_in_text
()
find_links_in_text
()
find_links_in_text
(
1
)
find_links_in_text
(
1
)
find_links_in_text
(
True
)
find_links_in_text
(
True
)
def
test_if_check_duplicate_links_has_the_correct_return
(
self
):
result_1
=
check_duplicate_links
(
self
.
duplicate_links
)
result_2
=
check_duplicate_links
(
self
.
no_duplicate_links
)
self
.
assertIsInstance
(
result_1
,
tuple
)
self
.
assertIsInstance
(
result_2
,
tuple
)
has_duplicate_links
,
links
=
result_1
no_duplicate_links
,
no_links
=
result_2
self
.
assertTrue
(
has_duplicate_links
)
self
.
assertFalse
(
no_duplicate_links
)
self
.
assertIsInstance
(
links
,
list
)
self
.
assertIsInstance
(
no_links
,
list
)
self
.
assertEqual
(
len
(
links
),
2
)
self
.
assertEqual
(
len
(
no_links
),
0
)
def
test_if_fake_user_agent_has_a_str_as_return
(
self
):
def
test_if_fake_user_agent_has_a_str_as_return
(
self
):
user_agent
=
fake_user_agent
()
user_agent
=
fake_user_agent
()
self
.
assertIsInstance
(
user_agent
,
str
)
self
.
assertIsInstance
(
user_agent
,
str
)
...
...
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