def test_add_artifact_missing_value(self): step_result = StepResult('step1', 'sub1', 'implementer1') with self.assertRaisesRegex(StepRunnerException, r"Value is required to add artifact"): step_result.add_artifact('name1', '', 'description1')
def test_get_artifact_value(self): step_result_expected = 'value1' step_result = StepResult('step1', 'sub1', 'implementer1') step_result.add_artifact('artifact1', 'value1', 'description1') self.assertEqual(step_result.get_artifact_value('artifact1'), step_result_expected)
def test_get_step_result_dict_with_env(self): step_result = StepResult( step_name='foo', sub_step_name= 'tests.helpers.sample_step_implementers.FooStepImplementer', sub_step_implementer_name= 'tests.helpers.sample_step_implementers.FooStepImplementer', environment='blarg') step_result.add_artifact(name='art-str', value='hello') step_result.add_artifact(name='art-bool-t', value=True) step_result.add_artifact(name='art-bool-f', value=False) step_result.add_artifact(name='art-desc', value='world', description='test artifact') step_result.add_evidence(name='evi-str', value='hello') step_result.add_evidence(name='evi-bool-t', value=True) step_result.add_evidence(name='evi-bool-f', value=False) step_result.add_evidence(name='evi-desc', value='world', description='test evidence') expected = { 'blarg': { 'foo': { 'tests.helpers.sample_step_implementers.FooStepImplementer': { 'artifacts': [{ 'description': '', 'name': 'art-str', 'value': 'hello' }, { 'description': '', 'name': 'art-bool-t', 'value': True }, { 'description': '', 'name': 'art-bool-f', 'value': False }, { 'description': 'test artifact', 'name': 'art-desc', 'value': 'world' }], 'evidence': [{ 'description': '', 'name': 'evi-str', 'value': 'hello' }, { 'description': '', 'name': 'evi-bool-t', 'value': True }, { 'description': '', 'name': 'evi-bool-f', 'value': False }, { 'description': 'test evidence', 'name': 'evi-desc', 'value': 'world' }], 'message': '', 'sub-step-implementer-name': 'tests.helpers.sample_step_implementers.FooStepImplementer', 'success': True } } } } self.assertEqual(expected, step_result.get_step_result_dict())