コード例 #1
0
class TestResult_test2(unittest.TestCase):
    def setUp(self):
        self.tester = component()
        self.trcomp = TestResult()
        self.trcomp.activate()
        self.pm = postman()
        self.pm.activate()
        self.tester.activate()
        #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
        self.pm.registerlinkage(
            linkage(source=self.tester,
                    sink=self.trcomp,
                    sourcebox="outbox",
                    sinkbox="inbox"))
        self.pm.registerlinkage(
            linkage(source=self.tester,
                    sink=self.trcomp,
                    sourcebox="signal",
                    sinkbox="control"))

    def runtestsystem(self):
        for i in xrange(5):
            self.trcomp.next()
            self.pm.domessagedelivery()

    def test_trueInput1(self):
        "mainBody - Checks that system keeps running when true value messages are sent to the inbox"
        self.tester.send(1)
        self.runtestsystem()

    def test_falseInput1(self):
        "mainBody - Checks that an AssertionError is raised when a false value message is sent to the inbox."
        self.tester.send(0)
        self.failUnlessRaises(AssertionError, self.runtestsystem)

    def test_trueInput2(self):
        "mainBody - Checks that system keeps running when true value messages are sent to the inbox. Repeated test."
        for i in xrange(1, 100):
            self.tester.send(i)
            self.runtestsystem()

    def test_falseInput2(self):
        "mainBody - Checks that an AssertionError is raised when false value messages are sent to the inbox after a series of true ones. Repeated test."
        for i in xrange(1, 100):
            self.tester.send(i)
            self.runtestsystem()
        self.tester.send(False)
        self.failUnlessRaises(AssertionError, self.runtestsystem)

    def test_stopSystem1(self):
        "mainBody - Checks that a StopSystem message sent to the control causes StopSystemException."
        self.tester.send(StopSystem(), "signal")
        self.failUnlessRaises(StopSystemException, self.runtestsystem)

    def test_stopSystem2(self):
        "mainBody - Checks that a StopSystem message sent to the control causes StopSystemException and that this stops the scheduler."
        self.tester.send(StopSystem(), "signal")
        self.failUnlessRaises(StopSystemException, scheduler.run.runThreads)
コード例 #2
0
class TestResult_test2(unittest.TestCase):
    def setUp(self):
        self.tester = component()
        self.trcomp = TestResult()
        self.trcomp.activate()
        self.pm = postman()
        self.pm.activate()
        self.tester.activate()
        #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
        self.pm.registerlinkage(linkage(source = self.tester, sink = self.trcomp, sourcebox = "outbox", sinkbox = "inbox"))
        self.pm.registerlinkage(linkage(source = self.tester, sink = self.trcomp, sourcebox = "signal", sinkbox = "control"))

    def runtestsystem(self):
        for i in xrange(5):
            self.trcomp.next()
            self.pm.domessagedelivery()
        
    def test_trueInput1(self):
        "mainBody - Checks that system keeps running when true value messages are sent to the inbox"
        self.tester.send(1)
        self.runtestsystem()
        
    def test_falseInput1(self):
        "mainBody - Checks that an AssertionError is raised when a false value message is sent to the inbox."
        self.tester.send(0)
        self.failUnlessRaises(AssertionError, self.runtestsystem)
        
    def test_trueInput2(self):
        "mainBody - Checks that system keeps running when true value messages are sent to the inbox. Repeated test."
        for i in xrange(1,100):
            self.tester.send(i)
            self.runtestsystem()

    def test_falseInput2(self):
        "mainBody - Checks that an AssertionError is raised when false value messages are sent to the inbox after a series of true ones. Repeated test."
        for i in xrange(1,100):
            self.tester.send(i)
            self.runtestsystem()
        self.tester.send(False)
        self.failUnlessRaises(AssertionError, self.runtestsystem)
        
    def test_stopSystem1(self):
        "mainBody - Checks that a StopSystem message sent to the control causes StopSystemException."
        self.tester.send(StopSystem(), "signal")
        self.failUnlessRaises(StopSystemException, self.runtestsystem)
    
    def test_stopSystem2(self):
        "mainBody - Checks that a StopSystem message sent to the control causes StopSystemException and that this stops the scheduler."
        self.tester.send(StopSystem(), "signal")
        self.failUnlessRaises(StopSystemException, scheduler.run.runThreads)
コード例 #3
0
 def setUp(self):
     self.tester = component()
     self.trcomp = TestResult()
     self.trcomp.activate()
     self.pm = postman()
     self.pm.activate()
     self.tester.activate()
     #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
     self.pm.registerlinkage(
         linkage(source=self.tester,
                 sink=self.trcomp,
                 sourcebox="outbox",
                 sinkbox="inbox"))
     self.pm.registerlinkage(
         linkage(source=self.tester,
                 sink=self.trcomp,
                 sourcebox="signal",
                 sinkbox="control"))
コード例 #4
0
 def setUp(self):
     self.tester = component()
     self.trcomp = TestResult()
     self.trcomp.activate()
     self.pm = postman()
     self.pm.activate()
     self.tester.activate()
     #pipewidth = 1 implies 2 items in the linkage.  One in outbox and one in sourcebox.  Need to change this code if these semantics change.
     self.pm.registerlinkage(linkage(source = self.tester, sink = self.trcomp, sourcebox = "outbox", sinkbox = "inbox"))
     self.pm.registerlinkage(linkage(source = self.tester, sink = self.trcomp, sourcebox = "signal", sinkbox = "control"))
コード例 #5
0
 def test_smoketest2(self):
     """__init__ - Checks the created component has the correct inboxes and outboxes ("inbox", "control", "outbox")."""
     self.failUnless(testInterface(TestResult(),
                                   (["inbox", "control"], [])))
コード例 #6
0
 def test_smoketest1(self):
     "__init__ - Object creation no arguments."
     self.failUnless(TestResult())