コード例 #1
0
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)
コード例 #2
0
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)
コード例 #3
0
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)
コード例 #4
0
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)
コード例 #5
0
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)
コード例 #6
0
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)
コード例 #7
0
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"}'
    )
コード例 #8
0
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"}'
    )
コード例 #9
0
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')
コード例 #10
0
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',
    })
コード例 #11
0
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')
コード例 #12
0
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',
    })