mirror of
https://github.com/public-apis/public-apis.git
synced 2025-06-08 05:41:54 +02:00
Create test to get_categories_content
This commit is contained in:
parent
40c5fa7a0c
commit
9d1bd19383
1 changed files with 30 additions and 0 deletions
|
@ -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):
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue