Beispiel #1
0
    def deserialize_raw_item(self, raw_item):
        data = {}
        for key, raw_value in raw_item.iteritems():
            try:
                value = Attribute.from_json(raw_value)
            except TypeError as e:
                logger.error(
                    'Failed to deserialize field {0}.{1} because: {2}'.format(
                        self.model.__class__.__name__, key, str(e)))
                raise

            data[key] = value

        return data
Beispiel #2
0
    def deserialize_raw_item(self, raw_item):
        data = {}
        for key, raw_value in raw_item.iteritems():
            try:
                value = Attribute.from_json(raw_value)
            except TypeError as e:
                logger.error('Failed to deserialize field {0}.{1} because: {2}'.format(
                    self.model.__class__.__name__,
                    key,
                    str(e)
                ))
                raise

            data[key] = value

        return data
Beispiel #3
0
def test_attribute_from_json():
    ('Attribute.from_json() should deserialize the given dict into a value')

    # Given an instance of attribute
    attribute = Attribute()

    # When I call from_json
    result = attribute.from_json(
        json.dumps({
            b'module': b'repocket.attributes',
            b'type': b'Attribute',
            b'value': b'foobar',
        }))

    # Then the result should be a value
    result.should.equal(b'foobar')
Beispiel #4
0
def test_attribute_from_json():
    ('Attribute.from_json() should deserialize the given dict into a value')

    # Given an instance of attribute
    attribute = Attribute()

    # When I call from_json
    result = attribute.from_json(json.dumps({
        b'module': b'repocket.attributes',
        b'type': b'Attribute',
        b'value': b'foobar',
    }))

    # Then the result should be a value
    result.should.equal(
        b'foobar'
    )