def test_get_placeholder_casesensitive(self): """Should raise KeyError because of case insitivity""" Placeholder.set_globalplaceholderfile(self._placeholder_test_file) exisiting_placeholder = "client" nonexisting_placeholder = "Client" expected_value = "Sgt Mustman" self.assertEqual(Placeholder.get_placeholder(exisiting_placeholder), expected_value) with self.assertRaises(KeyError): Placeholder.get_placeholder(nonexisting_placeholder)
def test_get_placeholder_from_testfile(self): """ Should return content of test file if key is in the file. """ existing_placeholder = "client" expected_value = "Sgt Mustman" Placeholder.set_globalplaceholderfile(self._placeholder_test_file) actual_value = Placeholder.get_placeholder(existing_placeholder) self.assertEqual(actual_value, expected_value)
def test_get_placeholder_with_nonexisting_key(self): """Should raise KeyError if the placeholder does not exist.""" with self.assertRaises(KeyError): Placeholder.get_placeholder('IDoNotExist')
def _collect(self) -> None: try: self.data = Placeholder.get_placeholder(self._placeholder) except KeyError: self.data = f"The placeholder '{self._placeholder}' has not been initialized yet."