def test_modal_template_subteam(self, select): Subrecord.get_form_template(team='test', subteam='really') select.assert_called_with([ 'modals/test/really/subrecord_modal.html', 'modals/test/subrecord_modal.html', 'modals/subrecord_modal.html', ])
def test_modal_template(self, get_template, get_form_template, find): get_form_template.return_value = "some_template" get_template.return_value = None Subrecord.get_modal_template() find.assert_called_with( ["base_templates/form_modal_base.html"] )
def test_detail_template_episode_type(self, find): Subrecord.get_detail_template(episode_type='Inpatient') find.assert_called_with([ 'records/inpatient/subrecord_detail.html', 'records/inpatient/subrecord.html', 'records/subrecord_detail.html', 'records/subrecord.html' ])
def test_display_template_subteam(self, select): Subrecord.get_display_template(team='test', subteam='really') select.assert_called_with([ 'records/test/really/subrecord.html', 'records/test/subrecord.html', 'records/subrecord.html' ])
def test_modal_template_episode_type(self, find): Subrecord.get_modal_template(episode_type='Inpatient') find.assert_called_with([ 'modals/inpatient/subrecord_modal.html', 'modals/subrecord_modal.html', 'base_templates/form_modal_base.html' ])
def test_form_template_episode_type(self, find): with warnings.catch_warnings(record=True): Subrecord.get_form_template(episode_type='Inpatient') find.assert_called_with([ 'forms/inpatient/subrecord_form.html', 'forms/subrecord_form.html' ])
def test_detail_template_list(self, find): with warnings.catch_warnings(record=True): patient_list = MagicMock() patient_list.get_prefixes.return_value = [] Subrecord.get_detail_template(patient_list=patient_list) find.assert_called_with( ['records/subrecord_detail.html', 'records/subrecord.html'])
def test_modal_template_list(self, find): patient_list = MagicMock() patient_list.get_template_prefixes = MagicMock(return_value=["test"]) Subrecord.get_modal_template(patient_list=patient_list) find.assert_called_with([ 'modals/test/subrecord_modal.html', 'modals/subrecord_modal.html', 'modal_base.html' ])
def test_display_template_list(self, find): patient_list = MagicMock() patient_list.get_template_prefixes = MagicMock(return_value=["test"]) Subrecord.get_display_template(patient_list=patient_list) find.assert_called_with([ 'records/test/subrecord.html', 'records/subrecord.html', ])
def test_detail_template_prefixes(self, find): find.return_value = None Subrecord.get_detail_template(prefixes=['onions']) self.assertEqual(find.call_args_list[0][0][0], [ 'records/onions/subrecord_detail.html', 'records/onions/subrecord.html', 'records/subrecord_detail.html', 'records/subrecord.html' ])
def test_detail_template_episode_type(self, find): with warnings.catch_warnings(record=True): find.return_value = None Subrecord.get_detail_template(episode_type='Inpatient') self.assertEqual(find.call_args_list[0][0][0], [ 'records/inpatient/subrecord_detail.html', 'records/inpatient/subrecord.html', 'records/subrecord_detail.html', 'records/subrecord.html' ])
def test_detail_template_prefixes(self, find): find.return_value = None Subrecord.get_detail_template(prefixes=['onions']) self.assertEqual(find.call_args_list[0][0][0], [ os.path.join('records', 'onions', 'subrecord_detail.html'), os.path.join('records', 'onions', 'subrecord.html'), os.path.join('records', 'subrecord_detail.html'), os.path.join('records', 'subrecord.html'), ])
def test_form_template_list(self, find): with warnings.catch_warnings(record=True): patient_list = MagicMock() patient_list.get_template_prefixes = MagicMock( return_value=["test"]) Subrecord.get_form_template(patient_list=patient_list) find.assert_called_with([ 'forms/test/subrecord_form.html', 'forms/subrecord_form.html' ])
def test_form_template_list_and_prefix(self, find): patient_list = MagicMock() patient_list.get_template_prefixes = MagicMock(return_value=["test"]) Subrecord.get_form_template(prefixes=["onions"], patient_list=patient_list) find.assert_called_with([ 'forms/onions/subrecord_form.html', 'forms/test/subrecord_form.html', 'forms/subrecord_form.html' ])
def test_build_template_selection_value_error(self): with self.assertRaises(ValueError) as v: with warnings.catch_warnings(record=True): episode_type = "Trees" patient_list = "Shrubbery" Subrecord._build_template_selection(suffix=".html", prefix="some_prefix", episode_type=episode_type, patient_list=patient_list) self.assertEqual( str(v), "you can not get both a patient list and episode type")
def test_detail_template_prefixes(self, find): find.return_value = None Subrecord.get_detail_template(prefixes=['onions']) self.assertEqual( find.call_args_list[0][0][0], [ os.path.join('records', 'onions', 'subrecord_detail.html'), os.path.join('records', 'onions', 'subrecord.html'), os.path.join('records', 'subrecord_detail.html'), os.path.join('records', 'subrecord.html'), ] )
def test_detail_template_prefixes(self, find): find.return_value = None Subrecord.get_detail_template(prefixes=['onions']) self.assertEqual( find.call_args_list[0][0][0], [ 'records/onions/subrecord_detail.html', 'records/onions/subrecord.html', 'records/subrecord_detail.html', 'records/subrecord.html' ] )
def test_modal_template_episode_type(self, find): with warnings.catch_warnings(record=True): find.return_value = None with patch.object(Subrecord, "get_form_template") as get_form: get_form.return_value = True Subrecord.get_modal_template(episode_type='Inpatient') self.assertEqual(find.call_args_list[0][0][0], [ 'modals/inpatient/subrecord_modal.html', 'modals/subrecord_modal.html', ]) self.assertEqual(find.call_args_list[1][0][0], ['base_templates/form_modal_base.html'])
def test_modal_template_list(self, find): with warnings.catch_warnings(record=True): find.return_value = None patient_list = MagicMock() patient_list.get_template_prefixes = MagicMock( return_value=["test"]) with patch.object(Subrecord, "get_form_template") as get_form: get_form.return_value = True Subrecord.get_modal_template(patient_list=patient_list) self.assertEqual(find.call_args_list[0][0][0], [ 'modals/test/subrecord_modal.html', 'modals/subrecord_modal.html', ]) self.assertEqual(find.call_args_list[1][0][0], ['base_templates/form_modal_base.html'])
def test_get_template_with_prefixes(self, find): find.return_value = "found" result = Subrecord._get_template("a_{}_b", prefixes=["onions"]) find.assert_called_once_with( [os.path.join("a_onions", "subrecord_b"), "a_subrecord_b"]) self.assertEqual(result, "found")
def test_get_template_with_prefixes(self, find): find.return_value = "found" result = Subrecord._get_template("a_{}_b", prefixes=["onions"]) find.assert_called_once_with([ os.path.join("a_onions", "subrecord_b"), "a_subrecord_b" ]) self.assertEqual(result, "found")
def test_build_template_selection_episode_type(self, find): with warnings.catch_warnings(record=True): episode_type = "Trees" result = Subrecord._build_template_selection( suffix=".html", prefix="some_prefix", episode_type=episode_type) self.assertEqual([ 'some_prefix/trees/subrecord.html', 'some_prefix/subrecord.html' ], result)
def test_build_template_selection_patient_list(self): with warnings.catch_warnings(record=True): patient_list = MagicMock() patient_list.get_template_prefixes.return_value = ["trees"] result = Subrecord._build_template_selection( suffix=".html", prefix="some_prefix", patient_list=patient_list) self.assertEqual([ 'some_prefix/trees/subrecord.html', 'some_prefix/subrecord.html' ], result)
def test_modal_template_no_form_template(self, modal, find): modal.return_value = None Subrecord.get_modal_template() find.assert_called_with(['modals/subrecord_modal.html'])
def test_display_template(self, select): Subrecord.get_display_template() select.assert_called_with(['records/subrecord.html'])
def test_detail_template_team(self, select): Subrecord.get_detail_template(team='test') select.assert_called_with([ 'records/subrecord_detail.html', 'records/subrecord.html' ])
def test_form_template(self, find): Subrecord.get_form_template() find.assert_called_with(['forms/subrecord_form.html'])
def test_form_template(self, find): Subrecord.get_form_template() find.assert_called_with([os.path.join('forms', 'subrecord_form.html')])
def test_get_template(self, find): find.return_value = "found" result = Subrecord._get_template("a_{}_b") find.assert_called_once_with(["a_subrecord_b"]) self.assertEqual(result, "found")
def test_form_template_prefixes(self, find): Subrecord.get_form_template(prefixes=['onions']) find.assert_called_with([ 'forms/onions/subrecord_form.html', 'forms/subrecord_form.html' ])
def test_display_template(self, find): Subrecord.get_display_template() find.assert_called_with([os.path.join('records', 'subrecord.html')])
def test_detail_template(self, find): Subrecord.get_detail_template() find.assert_called_with([ os.path.join('records', 'subrecord_detail.html'), os.path.join('records', 'subrecord.html'), ])
def test_detail_template(self, find): Subrecord.get_detail_template() find.assert_called_with([ 'records/subrecord_detail.html', 'records/subrecord.html' ])
def test_get_modal_template_does_not_exist(self): self.assertEqual(None, Subrecord.get_modal_template())
def test_get_form_url(self): url = Subrecord.get_form_url() self.assertEqual(url, '/templates/forms/subrecord.html')
def test_form_template_prefixes(self, find): Subrecord.get_form_template(prefixes=['onions']) find.assert_called_with( ['forms/onions/subrecord_form.html', 'forms/subrecord_form.html'])
def test_form_template(self, select): Subrecord.get_form_template() select.assert_called_with(['modals/subrecord_modal.html'])
def test_form_template_prefixes(self, find): Subrecord.get_form_template(prefixes=['onions']) find.assert_called_with([ os.path.join('forms', 'onions', 'subrecord_form.html'), os.path.join('forms', 'subrecord_form.html'), ])
def test_modal_template_no_form_template(self, modal, find): modal.return_value = None Subrecord.get_modal_template() find.assert_called_with([os.path.join('modals', 'subrecord_modal.html')])
def test_modal_template_no_form_template(self, modal, find): modal.return_value = None Subrecord.get_modal_template() find.assert_called_with( [os.path.join('modals', 'subrecord_modal.html')])
def test_display_template(self, find): Subrecord.get_display_template() find.assert_called_with(['records/subrecord.html'])