def test_data_setter(self): """ Should add the provided value as data object to its data object list :return: """ from baseclasses.artefact import ArtefactBase artefact = ArtefactBase(parent=None, parameters={}) artefact.data = "Some data" self.assertEqual(len(artefact.data), 1)
def test_data_setter_with_two_objects(self): """ Should append data to the data object array if there are more data objects to be collected :return: """ from baseclasses.artefact import ArtefactBase artefact = ArtefactBase(parent=None, parameters={}) artefact.data = "Some data" artefact.data = "More data" self.assertEqual(len(artefact.data), 2)
def test_data_setter_overwrite(self): """ Should overwrite existing collected data if None is provided as data object :return: """ from baseclasses.artefact import ArtefactBase artefact = ArtefactBase(parent=None, parameters={}) artefact.data = "Some data" artefact.data = "More data" artefact.data = None self.assertEqual(len(artefact.data), 0)
def test__init_description_properties_with_missing_resources(self): """ Should initialize properties _title, _description, and _collectionmethod with None """ from baseclasses.artefact import ArtefactBase artefact = ArtefactBase(parent=None, parameters={}) self.assertIsNone(artefact._title) self.assertIsNone(artefact._description) self.assertIsNone(artefact._collectionmethod)
def test_cache_parameters_not_defined(self): """ Should add the new placeholder to the global placeholders dictionary of Placeholders. """ from baseclasses.artefact import ArtefactBase from businesslogic.placeholders import Placeholder artefact = ArtefactBase(parent=None, parameters={}) expected_value = "value" expected_attribute = "attribute" artefact.cache_parameters({expected_attribute: expected_value}) try: actual_value = Placeholder._instruction_placeholders[ expected_attribute] self.assertEqual(expected_value, actual_value) except Exception: self.fail()
def store_artefact(self, artefact: ArtefactBase, callpath: str): self._write_protocol_entry(entrydata=artefact.getdocumentation(), entryheader=callpath) self._write_protocol_entry(entryheader='', entrydata=' ') if artefact.data is None: self._write_protocol_entry( entrydata="Could not collect data for artefact '{}'\n" "due to unhandled exception.".format(str(type(artefact))), entryheader='') else: with suppress(TypeError): self._write_protocol_entry(entrydata=str(artefact), entryheader='') self._write_protocol_entry(entryheader='', entrydata=' ')