diff options
author | BonfaceKilz | 2020-11-21 10:14:03 +0300 |
---|---|---|
committer | GitHub | 2020-11-21 10:14:03 +0300 |
commit | 5cac7531b517f96af9bf80066dc7faad396742f6 (patch) | |
tree | 7a78bed274abdc1760edbeb0b616deed134e5077 /wqflask/tests | |
parent | 6ed037083f0b2bac95021e5fb00c0c8877422a47 (diff) | |
parent | 4a16262f1f8097122ed0bedf2e92211627ad223a (diff) | |
download | genenetwork2-5cac7531b517f96af9bf80066dc7faad396742f6.tar.gz |
Merge pull request #488 from BonfaceKilz/feature/fetch-md-files-from-gh-docs-repo
Feature/fetch md files from gh docs repo
Diffstat (limited to 'wqflask/tests')
-rw-r--r-- | wqflask/tests/unit/wqflask/test_markdown_routes.py | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/wqflask/tests/unit/wqflask/test_markdown_routes.py b/wqflask/tests/unit/wqflask/test_markdown_routes.py index 3adf63e5..90e0f17c 100644 --- a/wqflask/tests/unit/wqflask/test_markdown_routes.py +++ b/wqflask/tests/unit/wqflask/test_markdown_routes.py @@ -3,28 +3,25 @@ import unittest from unittest import mock +from dataclasses import dataclass from wqflask.markdown_routes import render_markdown +@dataclass class MockRequests404: - @property - def status_code(self): - return 404 + status_code: int = 404 -class MockRequests200: - @property - def status_code(self): - return 200 - @property - def content(self): - return b""" +@dataclass +class MockRequests200: + status_code: int = 200 + content: str = b""" # Glossary This is some content ## Sub-heading -This is another sub-heading - """ +This is another sub-heading""" + class TestMarkdownRoutesFunctions(unittest.TestCase): """Test cases for functions in markdown_routes""" @@ -32,27 +29,26 @@ class TestMarkdownRoutesFunctions(unittest.TestCase): @mock.patch('wqflask.markdown_routes.requests.get') def test_render_markdown_when_fetching_locally(self, requests_mock): requests_mock.return_value = MockRequests404() - markdown_content = render_markdown("glossary.md") + markdown_content = render_markdown("general/glossary/glossary.md") requests_mock.assert_called_with( "https://raw.githubusercontent.com" - "/genenetwork/genenetwork2/" - "wqflask/wqflask/static/" - "glossary.md") + "/genenetwork/gn-docs/" + "master/general/" + "glossary/glossary.md") self.assertRegexpMatches(markdown_content, - "Glossary of Terms and Features") + "Content for general/glossary/glossary.md not available.") @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") + markdown_content = render_markdown("general/glossary/glossary.md") requests_mock.assert_called_with( "https://raw.githubusercontent.com" - "/genenetwork/genenetwork2/" - "wqflask/wqflask/static/" - "glossary.md") + "/genenetwork/gn-docs/" + "master/general/" + "glossary/glossary.md") self.assertEqual("""<h1>Glossary</h1> <p>This is some content</p> <h2>Sub-heading</h2> -<p>This is another sub-heading</p> -""", +<p>This is another sub-heading</p>""", markdown_content) |