コード例 #1
0
ファイル: GoalsContentHandler.py プロジェクト: we45/cairis
 def resetUseCaseEnvironmentAttributes(self):
   self.theEnvironmentName = ''    
   self.inPreconditions = 0
   self.thePreconditions = ''
   self.inPostconditions = 0
   self.thePostconditions = ''
   self.theSteps = Steps()
   self.theCurrentStep = None
   self.theCurrentStepNo = 0
   self.theExcName = ''
   self.theExcType = ''
   self.theExcValue = ''
   self.theExcCat = ''
   self.inDefinition = 0
   self.theDefinition = ''
コード例 #2
0
ファイル: test_UseCase.py プロジェクト: gkmacc/cairis
  def testUseCase(self):
    ucName = self.iUseCases[0]["theName"]
    ucAuthor = self.iUseCases[0]["theAuthor"]
    ucCode = self.iUseCases[0]["theCode"]
    ucDesc = self.iUseCases[0]["theDescription"]
    ucActor = self.iUseCases[0]["theActor"]
    ucEnv = self.iUseCases[0]["theEnvironments"][0]
    ucEnvName = ucEnv["theName"]
    ucPre = ucEnv["thePreconditions"]
    ucPost = ucEnv["thePostconditions"]
    ss = Steps()
    for ucStep in ucEnv["theFlow"]:
      ss.append(Step(ucStep["theDescription"]))  
    ucep = UseCaseEnvironmentProperties(ucEnvName,ucPre,ss,ucPost)
    iuc = UseCaseParameters(ucName,ucAuthor,ucCode,[ucActor],ucDesc,[],[ucep])
    b = Borg()
    b.dbProxy.addUseCase(iuc) 

    theUseCases = b.dbProxy.getUseCases()
    ouc = theUseCases[self.iUseCases[0]["theName"]]
    self.assertEqual(iuc.name(),ouc.name())
    self.assertEqual(iuc.tags(),ouc.tags())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.code(),ouc.code())
    self.assertEqual(iuc.actors(),ouc.actors())
    self.assertEqual(iuc.description(),ouc.description())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.environmentProperties()[0].preconditions(),ouc.environmentProperties()[0].preconditions())
    self.assertEqual(iuc.environmentProperties()[0].postconditions(),ouc.environmentProperties()[0].postconditions())

    iuc.theName = 'Updated name'
    iuc.setId(ouc.id())
    b.dbProxy.updateUseCase(iuc) 
    theUseCases = b.dbProxy.getUseCases()
    ouc = theUseCases['Updated name']
    self.assertEqual(iuc.name(),ouc.name())
    self.assertEqual(iuc.tags(),ouc.tags())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.code(),ouc.code())
    self.assertEqual(iuc.actors(),ouc.actors())
    self.assertEqual(iuc.description(),ouc.description())
    self.assertEqual(iuc.author(),ouc.author())
    self.assertEqual(iuc.environmentProperties()[0].preconditions(),ouc.environmentProperties()[0].preconditions())
    self.assertEqual(iuc.environmentProperties()[0].postconditions(),ouc.environmentProperties()[0].postconditions())

    b.dbProxy.deleteUseCase(ouc.id())
コード例 #3
0
 def resetUseCaseEnvironmentAttributes(self):
     self.theEnvironmentName = ''
     self.inPreconditions = 0
     self.thePreconditions = ''
     self.inPostconditions = 0
     self.thePostconditions = ''
     self.theSteps = Steps()
     self.theCurrentStep = None
     self.theCurrentStepNo = 0
     self.theExcName = ''
     self.theExcType = ''
     self.theExcValue = ''
     self.theExcCat = ''
     self.inDefinition = 0
     self.theDefinition = ''
     self.theCognitiveAttribute = {}
     self.theCognitiveAttribute['vigilance'] = (0, 'None')
     self.theCognitiveAttribute['situation awareness'] = (0, 'None')
     self.theCognitiveAttribute['stress'] = (0, 'None')
     self.theCognitiveAttribute['workload'] = (0, 'None')
     self.theCognitiveAttribute['risk awareness'] = (0, 'None')
コード例 #4
0
ファイル: UseCaseDAO.py プロジェクト: llewelld/cairis
 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
コード例 #5
0
    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:
                        s.append(
                            StepAttributes(step.text(), step.synopsis(),
                                           step.actor(), step.actorType(),
                                           step.tags()))
                    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 s in fake_prop['theSteps']:
                        steps.append(
                            Step(s['theStepText'], s['theSynopsis'],
                                 s['theActor'], s['theActorType'],
                                 s['theTags']))
                    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
コード例 #6
0
    def setUpClass(cls):
        call([os.environ['CAIRIS_CFG_DIR'] + "/initdb.sh"])
        cairis.core.BorgFactory.initialise()

        f = open(os.environ['CAIRIS_SRC'] + '/test/dataflow.json')
        d = json.load(f)
        f.close()
        iEnvironments = d['environments']
        iep1 = EnvironmentParameters(iEnvironments[0]["theName"],
                                     iEnvironments[0]["theShortCode"],
                                     iEnvironments[0]["theDescription"])
        b = Borg()
        b.dbProxy.addEnvironment(iep1)

        iRoles = d['roles']
        irp = RoleParameters(iRoles[0]["theName"], iRoles[0]["theType"],
                             iRoles[0]["theShortCode"],
                             iRoles[0]["theDescription"], [])
        b.dbProxy.addRole(irp)

        iUseCases = d['use_cases']
        ucName = iUseCases[0]["theName"]
        ucAuthor = iUseCases[0]["theAuthor"]
        ucCode = iUseCases[0]["theCode"]
        ucDesc = iUseCases[0]["theDescription"]
        ucActor = iUseCases[0]["theActor"]
        ucEnv = iUseCases[0]["theEnvironments"][0]
        ucEnvName = ucEnv["theName"]
        ucPre = ucEnv["thePreconditions"]
        ucPost = ucEnv["thePostconditions"]
        ss = Steps()
        for ucStep in ucEnv["theFlow"]:
            ss.append(Step(ucStep["theDescription"]))
        ucep = UseCaseEnvironmentProperties(ucEnvName, ucPre, ss, ucPost)
        iuc = UseCaseParameters(ucName, ucAuthor, ucCode, [ucActor], ucDesc,
                                [], [ucep])
        b = Borg()
        b.dbProxy.addUseCase(iuc)

        for iAsset in d['assets']:
            iaeps = [
                AssetEnvironmentProperties(
                    iAsset["theEnvironmentProperties"][0][0],
                    iAsset["theEnvironmentProperties"][0][1],
                    iAsset["theEnvironmentProperties"][0][2])
            ]
            iap = AssetParameters(iAsset["theName"], iAsset["theShortCode"],
                                  iAsset["theDescription"],
                                  iAsset["theSignificance"], iAsset["theType"],
                                  "0", "N/A", [], [], iaeps)
            b.dbProxy.addAsset(iap)

        for iObstacle in d['obstacles']:
            ioep = ObstacleEnvironmentProperties(
                iObstacle["theEnvironmentProperties"][0],
                iObstacle["theEnvironmentProperties"][1],
                iObstacle["theEnvironmentProperties"][2],
                iObstacle["theEnvironmentProperties"][3])
            iop = ObstacleParameters(iObstacle["theName"],
                                     iObstacle["theOriginator"], [], [ioep])
            b.dbProxy.addObstacle(iop)