diff options
author | BonfaceKilz | 2020-11-03 23:04:53 +0300 |
---|---|---|
committer | BonfaceKilz | 2020-11-03 23:04:53 +0300 |
commit | 5f6756f05baeeb6be34a079726d0df749a0557ec (patch) | |
tree | 71e1ad40aa29294ac05b22c4829547a9ddad365e /wqflask/tests/unit | |
parent | 3ca276a1e9d3aa29f037696b640c64b2d8629c7f (diff) | |
download | genenetwork2-5f6756f05baeeb6be34a079726d0df749a0557ec.tar.gz |
Fix false-positive tests
* wqflask/tests/unit/wqflask/test_markdown_routes.py:
(MockRequests404): Pass self in all properties.
(MockRequests200): Ditto.
(test_render_markdown): Rename to
test_render_markdown_when_fetching_locally.
(test_render_markdown_when_fetching_remotely): New test.
Diffstat (limited to 'wqflask/tests/unit')
-rw-r--r-- | wqflask/tests/unit/wqflask/test_markdown_routes.py | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/wqflask/tests/unit/wqflask/test_markdown_routes.py b/wqflask/tests/unit/wqflask/test_markdown_routes.py index 8b6f7490..3de14276 100644 --- a/wqflask/tests/unit/wqflask/test_markdown_routes.py +++ b/wqflask/tests/unit/wqflask/test_markdown_routes.py @@ -8,31 +8,30 @@ from wqflask.markdown_routes import render_markdown class MockRequests404: @property - def status_code(): + def status_code(self): return 404 class MockRequests200: @property - def status_code(): + def status_code(self): return 200 @property - def content(): - return """ - # Glossary + def content(self): + return b""" +# Glossary +This is some content - This is some content - - ## Sub-heading - This is another sub-heading +## 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 + def test_render_markdown_when_fetching_locally(self, requests_mock): + requests_mock.return_value = MockRequests404() markdown_content = render_markdown("glossary.md") requests_mock.assert_called_with( "https://raw.githubusercontent.com" @@ -41,3 +40,19 @@ class TestMarkdownRoutesFunctions(unittest.TestCase): "glossary.md") self.assertEqual("<h1>Content</h1>\n", markdown_content) + + @mock.patch('wqflask.markdown_routes.requests.get') + def test_render_markdown_when_fetching_remotely(self, requests_mock): + requests_mock.return_value = MockRequests200() + 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>Glossary</h1> +<p>This is some content</p> +<h2>Sub-heading</h2> +<p>This is another sub-heading</p> +""", + markdown_content) |