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
d04c02a7
Unverified
Commit
d04c02a7
authored
Jan 17, 2022
by
Matheus Felipe
Browse files
Create tests to check_cors
parent
347cd460
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_format.py
View file @
d04c02a7
...
@@ -9,6 +9,7 @@ from validate.format import check_title
...
@@ -9,6 +9,7 @@ from validate.format import check_title
from
validate.format
import
check_description
,
max_description_length
from
validate.format
import
check_description
,
max_description_length
from
validate.format
import
check_auth
,
auth_keys
from
validate.format
import
check_auth
,
auth_keys
from
validate.format
import
check_https
,
https_keys
from
validate.format
import
check_https
,
https_keys
from
validate.format
import
check_cors
,
cors_keys
class
TestValidadeFormat
(
unittest
.
TestCase
):
class
TestValidadeFormat
(
unittest
.
TestCase
):
...
@@ -338,3 +339,29 @@ class TestValidadeFormat(unittest.TestCase):
...
@@ -338,3 +339,29 @@ class TestValidadeFormat(unittest.TestCase):
self
.
assertIsInstance
(
err_msg
,
str
)
self
.
assertIsInstance
(
err_msg
,
str
)
self
.
assertEqual
(
err_msg
,
expected_err_msg
)
self
.
assertEqual
(
err_msg
,
expected_err_msg
)
def
test_check_cors_with_valid_cors
(
self
):
for
cors
in
cors_keys
:
with
self
.
subTest
():
err_msgs
=
check_cors
(
0
,
cors
)
self
.
assertIsInstance
(
err_msgs
,
list
)
self
.
assertEqual
(
len
(
err_msgs
),
0
)
self
.
assertEqual
(
err_msgs
,
[])
def
test_check_cors_with_invalid_cors
(
self
):
invalid_cors_keys
=
[
'yes'
,
'no'
,
'unknown'
,
'cors'
]
for
cors
in
invalid_cors_keys
:
with
self
.
subTest
():
err_msgs
=
check_cors
(
0
,
cors
)
self
.
assertIsInstance
(
err_msgs
,
list
)
self
.
assertEqual
(
len
(
err_msgs
),
1
)
err_msg
=
err_msgs
[
0
]
expected_err_msg
=
f
'(L001)
{
cors
}
is not a valid CORS option'
self
.
assertIsInstance
(
err_msg
,
str
)
self
.
assertEqual
(
err_msg
,
expected_err_msg
)
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