def test_unicode_from_string(): ('Unicode#from_string() should have cast the value as string') # Given an instance of unicode instance = Unicode() # When I call from_string result = instance.from_string('unsafestring') # Then the result should be a UUID result.should.be.an(unicode)
def test_unicode_get_base_type(): ('Unicode#get_base_type() should return the __base_type__') # Given an instance of unicode instance = Unicode() # When I call get_base_type result = instance.get_base_type() # Then the result should be bytes result.should.equal(unicode)
def test_unicode_to_string(): ('Unicode#to_string() should have cast the value as string') # Given an instance of unicode instance = Unicode() # When I call to_string result = instance.to_string(str(test_uuid)) # Then the result should be a string result.should.be.a(bytes)
def test_unicode_to_json(): ('Unicode.to_json() should deserialize the given dict into a value') # Given an instance of unicode instance = Unicode() # When I call to_json result = instance.to_json(u'unsafestring') # Then the result should be a value result.should.equal( '{"type": "Unicode", "value": "unsafestring", "module": "repocket.attributes"}' )
def test_unicode_from_json(): ('Unicode.from_json() should deserialize the given dict into a value') # Given an instance of unicode instance = Unicode() # When I call from_json result = instance.from_json(json.dumps({ b'module': b'repocket.attributes', b'type': b'Unicode', b'value': b'unsafestring', })) # Then the result should be a value result.should.equal(u'unsafestring')
def test_unicode_to_python(): ('Unicode#to_python() should prepare data to be serialized') # Given an instance of unicode instance = Unicode() # When I call to_python result = instance.to_python(u'unsafestring') # Then the result should be a dictionary with metadata result.should.equal({ 'module': 'repocket.attributes', 'type': 'Unicode', 'value': 'unsafestring', })
def test_unicode_from_python(): ('Unicode.from_python() should deserialize the given dict into a value') # Given an instance of unicode instance = Unicode() # When I call from_python result = instance.from_python({ b'module': b'repocket.attributes', b'type': b'Unicode', b'value': u'unsafestring', }) # Then the result should be a value result.should.equal('unsafestring')