From b59e9201541cf308e9d46d710553e574cd0fb334 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Wed, 23 Mar 2022 17:10:14 +0300 Subject: Create a new page to display case-attributes and their descriptions * wqflask/wqflask/metadata_edits.py: Import "gn3.db.sample_data.get_case_attributes". (show_case_attribute_columns): New function/ end-point to show case-attributes. * wqflask/tests/integration/wqflask/test_metadata_edits.py: New integration tests for the above. * wqflask/tests/integration/wqflask/__init__.py: New file. * wqflask/wqflask/templates/case_attributes.html: New template file to display the above. --- wqflask/tests/integration/wqflask/__init__.py | 0 .../integration/wqflask/test_metadata_edits.py | 41 ++++++++++++++++++++ wqflask/wqflask/metadata_edits.py | 12 ++++++ wqflask/wqflask/templates/case_attributes.html | 44 ++++++++++++++++++++++ 4 files changed, 97 insertions(+) create mode 100644 wqflask/tests/integration/wqflask/__init__.py create mode 100644 wqflask/tests/integration/wqflask/test_metadata_edits.py create mode 100644 wqflask/wqflask/templates/case_attributes.html (limited to 'wqflask') diff --git a/wqflask/tests/integration/wqflask/__init__.py b/wqflask/tests/integration/wqflask/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/wqflask/tests/integration/wqflask/test_metadata_edits.py b/wqflask/tests/integration/wqflask/test_metadata_edits.py new file mode 100644 index 00000000..4b9e017d --- /dev/null +++ b/wqflask/tests/integration/wqflask/test_metadata_edits.py @@ -0,0 +1,41 @@ +"""Tests for wqflask/wqflask/metadata_edits.py""" +import unittest +from unittest import mock + +from wqflask import app + + +class MetadataEditsTest(unittest.TestCase): + """Test Cases for MetadataEdits""" + + def setUp(self): + self.app = app.test_client() + self.app_context = app.app_context() + self.app_context.push() + + def tearDown(self): + self.app_context.pop() + + @mock.patch("wqflask.metadata_edits.get_case_attributes") + def test_show_case_attributes(self, mock_case_attrs): + """Test that case attributes are displayed correctly""" + mock_case_attrs.return_value = { + "Condition (1)": "", + "Tissue": "", + "Age": "Cum sociis natoque penatibus et magnis dis", + "Condition (4)": "Description A", + "Condition (5)": "Description B", + } + response = self.app.get( + "/datasets/case-attributes", follow_redirects=True + ).data.decode() + self.assertIn( + "
Header | +Description | + + + {% for key, value in case_attributes.items() %} +
---|---|
{{ key }} | {{ value }} | +