コード例 #1
0
 def test400_010_ShouldRunServiceRequest(self):
     myMonitor = Monitor.Monitor()
     env = Environment.Environment()
     env.setRotationalPeriod(1000000)
     myMonitor.configure(env)
     myMonitor.initialize(logFile="logfile.txt")
     self.assertEquals(
         myMonitor.serviceRequest(source="Controller", target="Device"), 0)
コード例 #2
0
 def test400_910ShouldRaiseExceptionOnMissingInitialization(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         env = Environment.Environment()
         env.setRotationalPeriod(1000000)
         myMonitor.configure(env)
         self.assertEquals(
             myMonitor.serviceRequest(source="Controller", target="Device"),
             0)
コード例 #3
0
 def test300_920ShouldRaiseExceptionOnPassingNonEnvironmentInstance(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         env = 2
         myMonitor.configure(env)
コード例 #4
0
 def test300_010_ShouldConfigureWithEnvironment(self):
     myMonitor = Monitor.Monitor()
     env = Environment.Environment()
     env.setRotationalPeriod(1000000)
     self.assertEquals(myMonitor.configure(env), True)
コード例 #5
0
 def test300_910ShouldRaiseExceptionOnMissingEnvironment(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         myMonitor.configure()
コード例 #6
0
 def test200_940ShouldRaiseExceptionOnMissingFileName(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         myMonitor.initialize()
コード例 #7
0
 def test200_950ShouldRaiseExceptionOnFileNotString(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         myMonitor.initialize(logFile=2)
コード例 #8
0
 def test200_930ShouldRaiseExceptionOnFileNameLessThanOne(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         myMonitor.initialize(logFile=".txt")
コード例 #9
0
 def test200_920ShouldRaiseExceptionOnIncorrectFileExtension(self):
     with self.assertRaises(ValueError) as context:
         myMonitor = Monitor.Monitor()
         myMonitor.initialize(logFile="logfile.csv")
コード例 #10
0
 def test200_010_ShouldInitializeWithLogFile(self):
     myMonitor = Monitor.Monitor()
     logFile = "logfile.txt"
     result = not os.path.isfile(logFile)
     self.assertEquals(myMonitor.initialize(logFile), result)
コード例 #11
0
 def test100_010_ShouldConstruct(self):
     self.assertIsInstance(Monitor.Monitor(), Monitor.Monitor)
コード例 #12
0
ファイル: ComponentFactory.py プロジェクト: Wilkhu90/COMP6700
    def getComponent(self):
        if (self.component['component'] == "Environment"):
            self.instance = Environment.Environment()
            parms = self.component['parms']
            if len(parms) == 0:
                raise ValueError(
                    "Controller.initialize:  Environment requires additional information."
                )
            for parm in parms:
                if (str(parm['name'])
                        == 'rotationalPeriod') and (parm['value'] != None):
                    self.instance.setRotationalPeriod((int)(parm['value']))
                elif (str(parm['name'])
                      == 'startTime') and (parm['value'] != None):
                    self.instance.setStartTime((int)(parm['value']))
                elif (str(parm['name'])
                      == 'degradation') and (parm['value'] != None):
                    self.instance.setDegradation((int)(parm['value']))
                else:
                    raise ValueError(
                        "Controller.initialize:  Environment requires additional information."
                    )
            return self.instance

        elif (self.component['component'] == "Monitor"):
            self.instance = Monitor.Monitor()
            parms = self.component['parms']
            if len(parms) == 0:
                raise ValueError(
                    "Controller.initialize:  Monitor requires additional information."
                )
            for parm in parms:
                if (str(parm['name']) == 'logFile'):
                    self.instance.initialize(str(parm['value']))
                else:
                    raise ValueError(
                        "Controller.initialize:  Monitor requires additional information."
                    )
            return self.instance

        elif (self.component['component'] == "StarSensor"):
            parms = self.component['parms']
            if len(parms) != 2:
                raise ValueError(
                    "Controller.initialize:  StarSensor requires additional information."
                )
            for parm in parms:
                if (str(parm['name']) == 'fieldOfView'):
                    self.instance = StarSensor.StarSensor(
                        (float)(parm['value']))
                elif (str(parm['name']) == 'starFile'):
                    pass
                else:
                    raise ValueError(
                        "Controller.initialize:  StarSensor requires additional information."
                    )
            for parm in parms:
                if (str(parm['name']) == 'starFile'):
                    self.instance.initializeSensor(str(parm['value']))
                elif (str(parm['name']) == 'fieldOfView'):
                    pass
                else:
                    raise ValueError(
                        "Controller.initialize:  StarSensor requires additional information."
                    )
            return self.instance

        elif (self.component['component'] == "Device"):
            self.instance = Device.Device()
            return self.instance
        elif (self.component['component'] == "SolarCollector"):
            self.instance = SolarCollector.SolarCollector()
            return self.instance
        else:
            raise ValueError(
                "Controller.initialize:  The device(s) mentioned in XML is incorrect."
            )