def runTest(self): #Reset the Main Presenter to be our own object. dM = MainData(mode=(0, 1)) self.mp = MainPresenter(dM=dM) self.assertEqual(self.mp.getModeTransition(), State.EVENTS.OFFLINE, "Expected offline, got live transition") dM = MainData(mode=(1, 0)) self.mp = MainPresenter(dM=dM) self.assertEqual(self.mp.getModeTransition(), State.EVENTS.LIVE, "Expected live, got offline transition")
def __init__(self, dM=None): #Create the data model and the state machine if dM == None: self.dataModel = MainData() else: self.dataModel = dM self.calcServ = CalculationService(self) self.stateMach = StateMachine(self)
def setUp(self): LuckyCalculationsTest.setUp(self) cc = CalibrationConfigData(calibDir=self.wdir, calibDS=self.dsCalibFile, calibUS=self.usCalibFile) dm = MainData(dataDir=self.wdir, usdsPair=[self.dsDataFile, self.usDataFile]) dm.calibConfigData = cc self.calcServ = CalculationService(None) self.calcServ.updateModel(dm)
def runTest(self): assert_array_equal(self.calcServ.dsData, np.loadtxt(self.dsDataFile, unpack=True), 'dsData ndarrays differ') assert_array_equal(self.calcServ.usData, np.loadtxt(self.usDataFile, unpack=True), 'usData ndarrays differ') assert_array_equal(self.calcServ.dsCalib, np.loadtxt(self.dsCalibFile, unpack=True), 'dsCalibFile ndarrays differ') assert_array_equal(self.calcServ.usCalib, np.loadtxt(self.usCalibFile, unpack=True), 'usCalibFile ndarrays differ') try: assert_array_equal(self.calcServ.dsCalibFile, self.calcServ.usCalibFile) self.fail('DS & US calibration ndarrays should differ') except: pass self.usCalibFile = os.path.join(self.wdir, 'Calib.txt') cc = CalibrationConfigData(calibDir=self.wdir, calibDS=self.dsCalibFile, calibUS=self.usCalibFile) dm = MainData(dataDir=self.wdir, usdsPair=[self.dsDataFile, self.usDataFile]) dm.calibConfigData = cc self.calcServ.updateModel(dm) assert_array_equal(self.calcServ.dsCalib, self.calcServ.usCalib) #Test the updateResults method self.calcServ.dsCalcs = mock_Calculations(2011.64, 2013.53) self.calcServ.usCalcs = mock_Calculations(2014.76, 2015.99) self.calcServ.updateResults() self.assertEquals( self.calcServ.planckResults, [2011.64, 2014.76, (2011.64 + 2014.76) / 2, 2011.64 - 2014.76], "planckResults not consistent with input mock data") self.assertEquals( self.calcServ.wienResults, [2013.53, 2015.99, (2013.53 + 2015.99) / 2, 2013.53 - 2015.99], "wienResults not consistent with input mock data")
def setUp(self): self.dM = MainData() self.state = None
def __init__(self): self.dataModel = MainData() self.calcServ = MockCalcServ()