about summary refs log tree commit diff
path: root/unit_tests/test_article_handler.py
blob: 17a19e00bb110161f40bb95449ddc51699346dd6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import unittest
import sys
sys.path.append("src") # Now we can import like we were in the src folder
import article_handler

class TestArticleHandler(unittest.TestCase):
    def test_parse_article_meta_data_excpetions(self):
        tests = [
                {'source': '', 'exception': article_handler.ArticleNoMetaData},
                {'source': '''---Joshua---''', 'exception': article_handler.ArticleMetaDataMalformed},
                {'source': '''---created: 2024-02-25---''', 'exception': article_handler.ArticleMetaDataMalformed},
                ]
        for test in tests:
            with self.assertRaises(test['exception']):
                article_handler.parse_article_meta_data(test['source'])

if __name__ == '__main__':
    unittest.main()