def test_decode_passed_encoded_datetime(self): d = datetime.strptime('1990-04-27', '%Y-%m-%d') encoded = { '__datetime__': True, 's': d.strftime('%Y%m%dT%H:%M:%S.%f'), } new_d = Header.decode(encoded) assert new_d == d
def test_decode_passed_encoded_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')) encoded = {} encoded[Header.name()] = True encoded['_id'] = h.get_id() encoded['_username'] = h.get_username() encoded['_session'] = h.get_session() encoded['_date'] = h.get_date() encoded['_type'] = h.get_type() encoded['_version'] = h.get_version() new_h = Header.decode(encoded) assert new_h.to_dict() == h.to_dict()
def test_decode_not_passed_encoded_Header_or_datetime(self): d = {'key': 'value'} o = Header.decode(d) assert o == d