浏览代码

Create test to get_categories_content

pull/3011/head
Matheus Felipe 2 年前
父节点
当前提交
9d1bd19383
找不到此签名对应的密钥 GPG 密钥 ID: AA785C523274872F
共有 1 个文件被更改,包括 30 次插入0 次删除
  1. +30
    -0
      scripts/tests/test_validate_format.py

+ 30
- 0
scripts/tests/test_validate_format.py 查看文件

@@ -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)

正在加载...
取消
保存