示例#1
0
 def test_encode_passed_Header(self):
     d = datetime.strptime('1990-04-27', '%Y-%m-%d')
     h = (Header().set_id('12345').set_username('senkwich').set_session(
         'mysession').set_date(d).set_type('some_type').set_version('1.0'))
     o = Header.encode(h)
     assert o[Header.name()]
     assert o['_id'] == h.get_id()
     assert o['_username'] == h.get_username()
     assert o['_session'] == h.get_session()
     assert o['_date'] == h.get_date()
     assert o['_type'] == h.get_type()
     assert o['_version'] == h.get_version()
示例#2
0
 def test_encode_passed_Header(self, header):
     assert Packet.encode(header) == Header.encode(header)
示例#3
0
 def test_encode_not_passed_Header_or_datetime(self):
     d = {'key': 'value'}
     o = Header.encode(d)
     assert o == d
示例#4
0
 def test_encode_passed_datetime(self):
     d = datetime.strptime('1990-04-27', '%Y-%m-%d')
     o = Header.encode(d)
     assert o['__datetime__']
     assert o['s'] == d.strftime('%Y%m%dT%H:%M:%S.%f')