|
| 1 | +import unittest |
| 2 | +from get_knowledge_base import adjust_knowledge_base_entry_path |
| 3 | + |
| 4 | +class TestGetKnowledgeBase(unittest.TestCase): |
| 5 | + |
| 6 | + def test_adjust_knowledgebase_entry_path(self): |
| 7 | + file_path = "./.tmp/defang-docs/2023-03-15-sample.md" |
| 8 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 9 | + self.assertEqual(adjusted_path, "/2023/03/15/sample") |
| 10 | + print("Test for adjust_knowledgebase_entry_path passed successfully!") |
| 11 | + |
| 12 | + def test_adjust_knowledgebase_entry_path_no_date(self): |
| 13 | + file_path = "./.tmp/defang-docs/sample.mdx" |
| 14 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 15 | + self.assertEqual(adjusted_path, "/sample") |
| 16 | + print("Test for adjust_knowledgebase_entry_path_no_date passed successfully!") |
| 17 | + |
| 18 | + def test_adjust_knowledgebase_entry_path_no_extension(self): |
| 19 | + file_path = "./.tmp/defang-docs/sample" |
| 20 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 21 | + self.assertEqual(adjusted_path, "/sample") |
| 22 | + print("Test for adjust_knowledgebase_entry_path_no_extension passed successfully!") |
| 23 | + |
| 24 | + def test_adjust_knowledgebase_entry_path_empty(self): |
| 25 | + file_path = "" |
| 26 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 27 | + self.assertEqual(adjusted_path, "") |
| 28 | + print("Test for adjust_knowledgebase_entry_path_empty passed successfully!") |
| 29 | + |
| 30 | + def test_adjust_knowledgebase_entry_path_date_at_end(self): |
| 31 | + file_path = "./.tmp/defang-docs/example-file-2023-03-15.md" |
| 32 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 33 | + self.assertEqual(adjusted_path, "/example-file-2023-03-15") |
| 34 | + print("Test for adjust_knowledgebase_entry_path_date_at_end passed successfully!") |
| 35 | + |
| 36 | + def test_adjust_knowledgebase_entry_path_date_at_middle(self): |
| 37 | + file_path = "./.tmp/defang-docs/example-file-2023-03-15-something-else.md" |
| 38 | + adjusted_path = adjust_knowledge_base_entry_path(file_path) |
| 39 | + self.assertEqual(adjusted_path, "/example-file-2023-03-15-something-else") |
| 40 | + print("Test for adjust_knowledgebase_entry_path_date_at_middle passed successfully!") |
| 41 | + |
| 42 | + |
| 43 | +if __name__ == '__main__': |
| 44 | + unittest.main() |
0 commit comments