def testStoppingNoRunset(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) exc = LiveException("Cannot stop run; no active runset") self.assertRaisesMsg(exc, live.stopping)
def testRunningNothing(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) exc = LiveException("Cannot check run state; no active runset") self.assertRaisesMsg(exc, live.running)
def testStartingNoStateArgs(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) self.assertRaisesMsg(LiveException("No stateArgs specified"), live.starting, None)
def testStartingNoRunSet(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) runCfg = "foo" runNum = 13579 cnc.setExpectedRunConfig(runCfg) cnc.setExpectedRunNumber(runNum) state = { "runConfig": runCfg, "runNumber": runNum } self.assertRaisesMsg(LiveException("Cannot create runset for \"%s\"" % runCfg), live.starting, state)
def testStartingNoRunNumKey(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) runCfg = "foo" runNum = 13579 cnc.setExpectedRunConfig(runCfg) cnc.setExpectedRunNumber(runNum) state = { "runConfig": runCfg, } exc = LiveException("stateArgs does not contain key \"runNumber\"") self.assertRaisesMsg(exc, live.starting, state)
def testStartingNoKeys(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) runCfg = "foo" runNum = 13579 cnc.setExpectedRunConfig(runCfg) cnc.setExpectedRunNumber(runNum) state = { } self.assertRaisesMsg(LiveException("No stateArgs specified"), live.starting, state)
def testRunningBadState(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) runCfg = "foo" runNum = 13579 runSet = MockRunSet(runCfg) cnc.setExpectedRunConfig(runCfg) cnc.setExpectedRunNumber(runNum) cnc.setRunSet(runSet) state = { "runConfig": runCfg, "runNumber": runNum } self.failUnless(live.starting(state), "starting failed") exc = LiveException("%s is not running (state = %s)" % (runSet, runSet.state())) self.assertRaisesMsg(exc, live.running)
def testStoppingError(self): cnc = MockCnC() log = MockLogger("liveLog") live = self.__createLive(cnc, log) runCfg = "foo" runNum = 13579 runSet = MockRunSet(runCfg) cnc.setExpectedRunConfig(runCfg) cnc.setExpectedRunNumber(runNum) cnc.setRunSet(runSet) state = { "runConfig": runCfg, "runNumber": runNum } self.failUnless(live.starting(state), "starting failed") runSet.setStopReturnError() exc = LiveException("Encountered ERROR while stopping run") self.assertRaisesMsg(exc, live.stopping)