Here are the examples of the python api nats.protocol.Protocol.PROTOCOL_TABLE taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
6 Examples
3
Example 1
Project: python-nats Source File: test_unit.py
def test_protocol_regular_in_table(self):
'should return the proto regular if in protocol table'
with patch.dict(Protocol.PROTOCOL_TABLE, {
'proto' : 'content'
}, clear=True):
self.assertEqual(Protocol.protocol_regular('proto'),
re.compile('content'))
3
Example 2
Project: python-nats Source File: test_unit.py
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'))
3
Example 3
Project: python-nats Source File: test_unit.py
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'))
3
Example 4
Project: python-nats Source File: test_unit.py
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'))
3
Example 5
Project: python-nats Source File: test_unit.py
def test_not_matched(self):
'should return the un-matched part of message'
with patch.dict(Protocol.PROTOCOL_TABLE, {
'proto' : 'content'
}, clear=True):
msg = 'content_not_matched'
self.assertEqual(Protocol.not_matched('proto', msg), '_not_matched')
3
Example 6
Project: python-nats Source File: test_unit.py
def test_matched(self):
'should return the matched part of message'
with patch.dict(Protocol.PROTOCOL_TABLE, {
'proto' : 'content'
}, clear=True):
msg = 'content_not_matched'
self.assertEqual(Protocol.matched('proto', msg), 'content')