def convert_props(self, real_props=None, fake_props=None): new_props = [] if real_props is not None: if len(real_props) > 0: for real_prop in real_props: assert isinstance(real_prop, UseCaseEnvironmentProperties) s = [] for step in real_prop.steps().theSteps: excs = [] for excKey in step.exceptions(): exc = step.exception(excKey) excs.append( ExceptionAttributes(exc[0], exc[1], exc[2], exc[3], exc[4])) s.append( StepAttributes(step.text(), step.synopsis(), step.actor(), step.actorType(), step.tags(), excs)) real_prop.theSteps = s new_props.append(real_prop) elif fake_props is not None: if len(fake_props) > 0: for fake_prop in fake_props: check_required_keys( fake_prop, UseCaseEnvironmentPropertiesModel.required) steps = Steps() for fs in fake_prop['theSteps']: aStep = Step(fs['theStepText'], fs['theSynopsis'], fs['theActor'], fs['theActorType'], fs['theTags']) for exc in fs['theExceptions']: aStep.addException( (exc['theName'], exc['theDimensionType'], exc['theDimensionValue'], exc['theCategoryName'], exc['theDescription'])) steps.append(aStep) fake_prop['theSteps'] = steps new_prop = UseCaseEnvironmentProperties( environmentName=fake_prop['theEnvironmentName'], preCond=fake_prop['thePreCond'], steps=fake_prop['theSteps'], postCond=fake_prop['thePostCond']) new_props.append(new_prop) else: self.close() raise MissingParameterHTTPError( param_names=['real_props', 'fake_props']) return new_props
def setUp(self): # region Class fields self.logger = logging.getLogger(__name__) self.existing_usecase_name = 'Test use case' self.existing_environment_name = 'Psychosis' self.existing_author = 'Shamal Faily' self.existing_code = 'TUC-1' self.existing_description = 'A test description' self.existing_actors = ['Researcher'] self.existing_precond = 'Test preconditions' self.existing_steps = [] anException = ExceptionAttributes('anException', 'requirement', 'Anonymisation guidelines', 'Confidentiality Threat', 'anException description') self.existing_steps.append( StepAttributes('Researcher does something', '', '', '', [], [anException])) self.existing_steps.append( StepAttributes('System does something', '', '', '', [], [])) self.existing_postcond = 'Test postconditions' usecase_class = UseCase.__module__ + '.' + UseCase.__name__