Example #1
0
 def test_wrong_syntax(self):
     for cmd in ['this', 'is', 'all wrong', 'and', 'should', 'not', 'turn',
                 'it on', 'or off']:
         deafDistributor(self.obj, cmd, None)
         assert self.obj.delegate.received == \
                                           [BadSyntaxEvent(syntaxmessage)],\
                "Failed on %r, self.delegate.received is %r" % \
                (cmd, self.delegate.received)
         self.obj.delegate.received = []
Example #2
0
 def test_wrong_syntax(self):
     for cmd in [
             'this', 'is', 'all wrong', 'and', 'should', 'not', 'turn',
             'it on', 'or off'
     ]:
         deafDistributor(self.obj, cmd, None)
         assert self.obj.delegate.received == \
                                           [BadSyntaxEvent(syntaxmessage)],\
                "Failed on %r, self.delegate.received is %r" % \
                (cmd, self.delegate.received)
         self.obj.delegate.received = []
Example #3
0
 def test_interesting_but_correct_syntaxes(self):
     for cmd in ["  %s", "%s ", "\t%s  ", "%s\t", "\t %s", "\r\t%s",
                 "%s\r ", "%s \r   ", "%s", "%s \t", "%s foo",
                 "%sbar"]:
         
         deafDistributor(self.obj, cmd % 'on', None)
         deafDistributor(self.obj, cmd % 'off', None)
         assert self.obj.delegate.received == [DeafnessOnEvent(),
                                               DeafnessOffEvent()], \
                "Failed on %r, self.delegate.received is %r" % \
                (cmd, self.delegate.received)
         self.obj.delegate.received = []
         
         deafDistributor(self.obj, cmd % 'ON', None)
         deafDistributor(self.obj, cmd % 'OFF', None)
         assert self.obj.delegate.received == [DeafnessOnEvent(),
                                               DeafnessOffEvent()], \
                "Failed on %r, self.delegate.received is %r" % \
                (cmd, self.delegate.received)
         self.obj.delegate.received = []
Example #4
0
    def test_interesting_but_correct_syntaxes(self):
        for cmd in [
                "  %s", "%s ", "\t%s  ", "%s\t", "\t %s", "\r\t%s", "%s\r ",
                "%s \r   ", "%s", "%s \t", "%s foo", "%sbar"
        ]:

            deafDistributor(self.obj, cmd % 'on', None)
            deafDistributor(self.obj, cmd % 'off', None)
            assert self.obj.delegate.received == [DeafnessOnEvent(),
                                                  DeafnessOffEvent()], \
                   "Failed on %r, self.delegate.received is %r" % \
                   (cmd, self.delegate.received)
            self.obj.delegate.received = []

            deafDistributor(self.obj, cmd % 'ON', None)
            deafDistributor(self.obj, cmd % 'OFF', None)
            assert self.obj.delegate.received == [DeafnessOnEvent(),
                                                  DeafnessOffEvent()], \
                   "Failed on %r, self.delegate.received is %r" % \
                   (cmd, self.delegate.received)
            self.obj.delegate.received = []
Example #5
0
    def test_deaf_off_success_with_parsing(self):
        self.obj.deaf = True
        deafDistributor(self.obj, 'off', None)

        assert self.obj.delegate.received == [DeafnessOffEvent()], \
               "self.delegate.received is %r" % self.delegate.received
Example #6
0
    def test_deaf_off_failure_with_parsing(self):
        deafDistributor(self.obj, 'off', None)

        assert self.obj.delegate.received == [DeafnessOffAlreadyEvent()], \
               "self.delegate.received is %r" % self.delegate.received
Example #7
0
    def test_deaf_on_success_with_parsing(self):
        deafDistributor(self.obj, 'on', None)

        assert self.obj.delegate.received == [DeafnessOnEvent()], \
               "self.delegate.received is %r" % self.delegate.received
Example #8
0
    def test_deaf_off_failure_with_parsing(self):
        deafDistributor(self.obj, 'off', None)

        assert self.obj.delegate.received == [DeafnessOffAlreadyEvent()], \
               "self.delegate.received is %r" % self.delegate.received
Example #9
0
    def test_deaf_on_success_with_parsing(self):
        deafDistributor(self.obj, 'on', None)

        assert self.obj.delegate.received == [DeafnessOnEvent()], \
               "self.delegate.received is %r" % self.delegate.received
Example #10
0
    def test_deaf_off_success_with_parsing(self):
        self.obj.deaf = True
        deafDistributor(self.obj, 'off', None)

        assert self.obj.delegate.received == [DeafnessOffEvent()], \
               "self.delegate.received is %r" % self.delegate.received