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 = []
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 = []
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 = []
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 = []
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
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
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