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
eeaa7c07
Unverified
Commit
eeaa7c07
authored
Jan 17, 2022
by
Matheus Felipe
Browse files
Create tests to check_entry
parent
54787556
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_format.py
View file @
eeaa7c07
...
...
@@ -10,6 +10,7 @@ from validate.format import check_description, max_description_length
from
validate.format
import
check_auth
,
auth_keys
from
validate.format
import
check_https
,
https_keys
from
validate.format
import
check_cors
,
cors_keys
from
validate.format
import
check_entry
class
TestValidadeFormat
(
unittest
.
TestCase
):
...
...
@@ -323,3 +324,33 @@ class TestValidadeFormat(unittest.TestCase):
self
.
assertIsInstance
(
err_msg
,
str
)
self
.
assertEqual
(
err_msg
,
expected_err_msg
)
def
test_check_entry_with_correct_segments
(
self
):
correct_segments
=
[
'[A](https://www.ex.com)'
,
'Desc'
,
'`apiKey`'
,
'Yes'
,
'Yes'
]
err_msgs
=
check_entry
(
0
,
correct_segments
)
self
.
assertIsInstance
(
err_msgs
,
list
)
self
.
assertEqual
(
len
(
err_msgs
),
0
)
self
.
assertEqual
(
err_msgs
,
[])
def
test_check_entry_with_incorrect_segments
(
self
):
incorrect_segments
=
[
'[A API](https://www.ex.com)'
,
'desc.'
,
'yes'
,
'yes'
,
'yes'
]
err_msgs
=
check_entry
(
0
,
incorrect_segments
)
expected_err_msgs
=
[
'(L001) Title should not end with "... API". Every entry is an API here!'
,
'(L001) first character of description is not capitalized'
,
'(L001) description should not end with .'
,
'(L001) auth value is not enclosed with `backticks`'
,
'(L001) yes is not a valid Auth option'
,
'(L001) yes is not a valid HTTPS option'
,
'(L001) yes is not a valid CORS option'
]
self
.
assertIsInstance
(
err_msgs
,
list
)
self
.
assertEqual
(
len
(
err_msgs
),
7
)
for
err_msg
in
err_msgs
:
with
self
.
subTest
():
self
.
assertIsInstance
(
err_msg
,
str
)
self
.
assertEqual
(
err_msgs
,
expected_err_msgs
)
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