diff options
author | BonfaceKilz | 2020-11-03 22:45:44 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-11-03 22:45:44 +0300 |
commit | bb46ab063cc86525946563c809a896532d87147a (patch) | |
tree | 7ee39750be501402a5d75eefbf44cbb446432d23 | |
parent | 74550ef0c76a941c473c8d024ccc0a0403631c49 (diff) | |
download | genenetwork2-bb46ab063cc86525946563c809a896532d87147a.tar.gz |
Add basic tests for rendering_markdown
* wqflask/tests/unit/wqflask/test_markdown_routes.py: New tests.
-rw-r--r-- | wqflask/tests/unit/wqflask/test_markdown_routes.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/wqflask/tests/unit/wqflask/test_markdown_routes.py b/wqflask/tests/unit/wqflask/test_markdown_routes.py new file mode 100644 index 00000000..8b6f7490 --- /dev/null +++ b/wqflask/tests/unit/wqflask/test_markdown_routes.py @@ -0,0 +1,43 @@ +"""Test functions in markdown utils""" + +import unittest +from unittest import mock + +from wqflask.markdown_routes import render_markdown + + +class MockRequests404: + @property + def status_code(): + return 404 + +class MockRequests200: + @property + def status_code(): + return 200 + + @property + def content(): + return """ + # Glossary + + This is some content + + ## Sub-heading + This is another sub-heading + """ + +class TestMarkdownRoutesFunctions(unittest.TestCase): + """Test cases for functions in markdown_routes""" + + @mock.patch('wqflask.markdown_routes.requests.get') + def test_render_markdown(self, requests_mock): + requests_mock.return_value = MockRequests404 + markdown_content = render_markdown("glossary.md") + requests_mock.assert_called_with( + "https://raw.githubusercontent.com" + "/genenetwork/genenetwork2/" + "wqflask/wqflask/static/" + "glossary.md") + self.assertEqual("<h1>Content</h1>\n", + markdown_content) |