Browse Source

Create test to get_categories_content

pull/3011/head
Matheus Felipe 2 years ago
parent
commit
9d1bd19383
No known key found for this signature in database GPG Key ID: AA785C523274872F
1 changed files with 30 additions and 0 deletions
  1. +30
    -0
      scripts/tests/test_validate_format.py

+ 30
- 0
scripts/tests/test_validate_format.py View File

@@ -4,6 +4,7 @@ from email import message
import unittest

from validate.format import error_message
from validate.format import get_categories_content


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_hundred, '(L101) 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…
Cancel
Save