|
@@ -5,6 +5,7 @@ import unittest |
|
|
|
|
|
|
|
|
from validate.format import error_message |
|
|
from validate.format import error_message |
|
|
from validate.format import get_categories_content |
|
|
from validate.format import get_categories_content |
|
|
|
|
|
from validate.format import check_alphabetical_order |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestValidadeFormat(unittest.TestCase): |
|
|
class TestValidadeFormat(unittest.TestCase): |
|
@@ -60,3 +61,52 @@ class TestValidadeFormat(unittest.TestCase): |
|
|
|
|
|
|
|
|
with self.subTest(): |
|
|
with self.subTest(): |
|
|
self.assertEqual(res, ex_res) |
|
|
self.assertEqual(res, ex_res) |
|
|
|
|
|
|
|
|
|
|
|
def test_if_check_alphabetical_order_return_correct_msg_error(self): |
|
|
|
|
|
correct_lines = [ |
|
|
|
|
|
'### 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 |' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
incorrect_lines = [ |
|
|
|
|
|
'### A', |
|
|
|
|
|
'API | Description | Auth | HTTPS | CORS |', |
|
|
|
|
|
'|---|---|---|---|---|', |
|
|
|
|
|
'| [AB](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |', |
|
|
|
|
|
'| [AA](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |', |
|
|
|
|
|
'', |
|
|
|
|
|
'### B', |
|
|
|
|
|
'API | Description | Auth | HTTPS | CORS |', |
|
|
|
|
|
'|---|---|---|---|---|', |
|
|
|
|
|
'| [BB](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |', |
|
|
|
|
|
'| [BA](https://www.ex.com) | Desc | `apiKey` | Yes | Yes |' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
err_msgs_1 = check_alphabetical_order(correct_lines) |
|
|
|
|
|
err_msgs_2 = check_alphabetical_order(incorrect_lines) |
|
|
|
|
|
|
|
|
|
|
|
self.assertIsInstance(err_msgs_1, list) |
|
|
|
|
|
self.assertIsInstance(err_msgs_2, list) |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(len(err_msgs_1), 0) |
|
|
|
|
|
self.assertEqual(len(err_msgs_2), 2) |
|
|
|
|
|
|
|
|
|
|
|
expected_err_msgs = [ |
|
|
|
|
|
'(L001) A category is not alphabetical order', |
|
|
|
|
|
'(L007) B category is not alphabetical order' |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
for err_msg, ex_err_msg in zip(err_msgs_2, expected_err_msgs): |
|
|
|
|
|
|
|
|
|
|
|
with self.subTest(): |
|
|
|
|
|
self.assertEqual(err_msg, ex_err_msg) |