Add regression test

This commit is contained in:
Daniel A. Wozniak 2019-04-30 01:16:56 +00:00 committed by Pedro Algarvio
parent ce782ff27a
commit a36b15e449
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -264,3 +264,27 @@ class SREQTestCase(TestCase):
# ensure no exceptions when we go to destroy the sreq, since __del__
# swallows exceptions, we have to call destroy directly
sreq.destroy()
def test_raw_vs_encoding_none(self):
'''
Test that we handle the new raw parameter in 5.0.2 correctly based on
encoding. When encoding is None loads should return bytes
'''
payload = salt.payload.Serial('msgpack')
dtvalue = datetime.datetime(2001, 2, 3, 4, 5, 6, 7)
idata = {dtvalue: 'strval'}
sdata = payload.dumps(idata.copy())
odata = payload.loads(sdata, encoding=None)
assert isinstance(odata[dtvalue], six.binary_type)
def test_raw_vs_encoding_utf8(self):
'''
Test that we handle the new raw parameter in 5.0.2 correctly based on
encoding. When encoding is utf-8 loads should return unicode
'''
payload = salt.payload.Serial('msgpack')
dtvalue = datetime.datetime(2001, 2, 3, 4, 5, 6, 7)
idata = {dtvalue: 'strval'}
sdata = payload.dumps(idata.copy())
odata = payload.loads(sdata, encoding='utf-8')
assert isinstance(odata[dtvalue], six.text_type)