Exemplo n.º 1
0
    def test_ActivityOnAnyExceptionalResultsInMessageOnThatExceptionalsService(self):
        "main - Activity on a selectable results in a message appearing in the service provided to the selector for that selectable"

        MOCKSELECTORMODULE = MockSelect(results=[ ([],[],["LOOKINGFORTHIS"]), 
                                                  ([],[],["THENFORTHIS"]), 
                                                  ([],[],["ANDTHENFORTHIS"]) ])
        SELECTORMODULE.select = MOCKSELECTORMODULE
        S = Selector()
        S.activate()
        for i in xrange(5): S.next()
        D = Axon.Component.component()
        E = Axon.Component.component()
        F = Axon.Component.component()
        dummyservice1 = (D, "inbox")
        S._deliver(newExceptional(S,( dummyservice1, "LOOKINGFORTHIS") ),"notify")
        dummyservice2 = (E, "inbox")
        S._deliver(newExceptional(S,( dummyservice2, "THENFORTHIS") ),"notify")
        dummyservice3 = (F, "inbox")
        S._deliver(newExceptional(S,( dummyservice3, "ANDTHENFORTHIS") ),"notify")

        for i in xrange(5):
            S.next();
            try:
               S.postoffice.next()
            except:
               pass
        selectable = D.recv("inbox")
        self.assertEqual(selectable,"LOOKINGFORTHIS")#, "The value returned should be the selectable we originally asked for")
        selectable = E.recv("inbox")
        self.assertEqual(selectable,"THENFORTHIS")#, "The value returned should be the selectable we originally asked for")
        selectable = F.recv("inbox")
        self.assertEqual(selectable,"ANDTHENFORTHIS")#, "The value returned should be the selectable we originally asked for")
Exemplo n.º 2
0
    def test_ActivityOnAnyExceptionalResultsInMessageOnThatExceptionalsService(
            self):
        "main - Activity on a selectable results in a message appearing in the service provided to the selector for that selectable"

        MOCKSELECTORMODULE = MockSelect(results=[(
            [], [],
            ["LOOKINGFORTHIS"]), ([], [],
                                  ["THENFORTHIS"]), ([], [],
                                                     ["ANDTHENFORTHIS"])])
        SELECTORMODULE.select = MOCKSELECTORMODULE
        S = Selector()
        S.activate()
        for i in xrange(5):
            S.next()
        D = Axon.Component.component()
        E = Axon.Component.component()
        F = Axon.Component.component()
        dummyservice1 = (D, "inbox")
        S._deliver(newExceptional(S, (dummyservice1, "LOOKINGFORTHIS")),
                   "notify")
        dummyservice2 = (E, "inbox")
        S._deliver(newExceptional(S, (dummyservice2, "THENFORTHIS")), "notify")
        dummyservice3 = (F, "inbox")
        S._deliver(newExceptional(S, (dummyservice3, "ANDTHENFORTHIS")),
                   "notify")

        for i in xrange(5):
            S.next()
            try:
                S.postoffice.next()
            except:
                pass
        selectable = D.recv("inbox")
        self.assertEqual(
            selectable, "LOOKINGFORTHIS"
        )  #, "The value returned should be the selectable we originally asked for")
        selectable = E.recv("inbox")
        self.assertEqual(
            selectable, "THENFORTHIS"
        )  #, "The value returned should be the selectable we originally asked for")
        selectable = F.recv("inbox")
        self.assertEqual(
            selectable, "ANDTHENFORTHIS"
        )  #, "The value returned should be the selectable we originally asked for")
Exemplo n.º 3
0
    def test_RemoveExceptional_ResultsInExceptionalNoLongerBeingSelectedOrWiredIn(self):
        "main - Sending a remove exceptional message unwires/links a component, and also removes it's selectable from the exceptionals list"
        MOCKSELECTORMODULE = MockSelect(results=[ ([], [], [] )])
        SELECTORMODULE.select = MOCKSELECTORMODULE
        S = Selector()
        S.activate()
        for i in xrange(100): S.next()
        D = Axon.Component.component() 
        dummyservice = (D, "inbox")
        S._deliver(newExceptional(S,( dummyservice, "LOOKINGFORTHIS") ),"notify")
        S._deliver(removeExceptional(S,"LOOKINGFORTHIS"),"notify")

        for i in xrange(100):
            S.next();
            try:
               S.postoffice.next()
            except:
               pass
        self.assert_( len(D.inboxes["inbox"]) == 0 )
Exemplo n.º 4
0
    def test_RemoveExceptional_ResultsInExceptionalNoLongerBeingSelectedOrWiredIn(
            self):
        "main - Sending a remove exceptional message unwires/links a component, and also removes it's selectable from the exceptionals list"
        MOCKSELECTORMODULE = MockSelect(results=[([], [], [])])
        SELECTORMODULE.select = MOCKSELECTORMODULE
        S = Selector()
        S.activate()
        for i in xrange(100):
            S.next()
        D = Axon.Component.component()
        dummyservice = (D, "inbox")
        S._deliver(newExceptional(S, (dummyservice, "LOOKINGFORTHIS")),
                   "notify")
        S._deliver(removeExceptional(S, "LOOKINGFORTHIS"), "notify")

        for i in xrange(100):
            S.next()
            try:
                S.postoffice.next()
            except:
                pass
        self.assert_(len(D.inboxes["inbox"]) == 0)