def test_nonexist_proto(self): 'should return False if proto not in table' with patch.dict(Protocol.PROTOCOL_TABLE, { 'proto' : 'content' }, clear=True): msg = 'content' self.assertFalse(Protocol.assert_protocol_type(msg, 'nonexist'))
def test_assert_wrong_proto_type(self): 'should return False if msg not matched the reg of given proto' with patch.dict(Protocol.PROTOCOL_TABLE, { 'proto' : 'content' }, clear=True): msg = 'somemsg' self.assertFalse(Protocol.assert_protocol_type(msg, 'proto'))
def test_assert_right_proto_type(self): 'should return True if the msg if matched the reg of given proto' with patch.dict(Protocol.PROTOCOL_TABLE, { 'proto' : 'content' }, clear=True): msg = 'content' self.assertTrue(Protocol.assert_protocol_type(msg, 'proto'))
def test_nonexist_proto(self): 'should return False if proto not in table' with patch.dict(Protocol.PROTOCOL_TABLE, {'proto': 'content'}, clear=True): msg = 'content' self.assertFalse(Protocol.assert_protocol_type(msg, 'nonexist'))
def test_assert_wrong_proto_type(self): 'should return False if msg not matched the reg of given proto' with patch.dict(Protocol.PROTOCOL_TABLE, {'proto': 'content'}, clear=True): msg = 'somemsg' self.assertFalse(Protocol.assert_protocol_type(msg, 'proto'))
def test_assert_right_proto_type(self): 'should return True if the msg if matched the reg of given proto' with patch.dict(Protocol.PROTOCOL_TABLE, {'proto': 'content'}, clear=True): msg = 'content' self.assertTrue(Protocol.assert_protocol_type(msg, 'proto'))