示例#1
0
    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)
示例#2
0
    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)
示例#3
0
    def testStartingNoStateArgs(self):
        cnc = MockCnC()
        log = MockLogger("liveLog")
        live = self.__createLive(cnc, log)

        self.assertRaisesMsg(LiveException("No stateArgs specified"),
                             live.starting, None)
示例#4
0
    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)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    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)