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
9d1bd193
Unverified
Commit
9d1bd193
authored
Jan 17, 2022
by
Matheus Felipe
Browse files
Create test to get_categories_content
parent
40c5fa7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
scripts/tests/test_validate_format.py
View file @
9d1bd193
...
@@ -4,6 +4,7 @@ from email import message
...
@@ -4,6 +4,7 @@ from email import message
import
unittest
import
unittest
from
validate.format
import
error_message
from
validate.format
import
error_message
from
validate.format
import
get_categories_content
class
TestValidadeFormat
(
unittest
.
TestCase
):
class
TestValidadeFormat
(
unittest
.
TestCase
):
...
@@ -30,3 +31,32 @@ class TestValidadeFormat(unittest.TestCase):
...
@@ -30,3 +31,32 @@ class TestValidadeFormat(unittest.TestCase):
self
.
assertEqual
(
err_msg_ten
,
'(L011) This is a unit test'
)
self
.
assertEqual
(
err_msg_ten
,
'(L011) This is a unit test'
)
self
.
assertEqual
(
err_msg_hundred
,
'(L101) This is a unit test'
)
self
.
assertEqual
(
err_msg_hundred
,
'(L101) This is a unit test'
)
self
.
assertEqual
(
err_msg_thousand
,
'(L1001) This is a unit test'
)
self
.
assertEqual
(
err_msg_thousand
,
'(L1001) This is a unit test'
)
def
test_if_get_categories_content_return_correct_data_of_categories
(
self
):
fake_contents
=
[
'### A'
,
'API | Description | Auth | HTTPS | CORS |'
,
'|---|---|---|---|---|'
,
'| [AA](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |'
,
'| [AB](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |'
,
''
,
'### B'
,
'API | Description | Auth | HTTPS | CORS |'
,
'|---|---|---|---|---|'
,
'| [BA](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |'
,
'| [BB](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |'
]
result
=
get_categories_content
(
fake_contents
)
self
.
assertIsInstance
(
result
,
tuple
)
categories
,
category_line_num
=
result
self
.
assertIsInstance
(
categories
,
dict
)
self
.
assertIsInstance
(
category_line_num
,
dict
)
expected_result
=
({
'A'
:
[
'AA'
,
'AB'
],
'B'
:
[
'BA'
,
'BB'
]},
{
'A'
:
0
,
'B'
:
6
})
for
res
,
ex_res
in
zip
(
result
,
expected_result
):
with
self
.
subTest
():
self
.
assertEqual
(
res
,
ex_res
)
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