Esempio n. 1
0
    def setup_class(cls):
        cls.raw_image_str = open(
            os.path.join(os.path.dirname(__file__), 'data/image.json')).read()
        cls.raw_images_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/images.json')).read()

        cls.raw_images_schema_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/images_schema.json')).read()
        cls.raw_image_schema_str = open(
            os.path.join(os.path.dirname(__file__),
                         'data/image_schema.json')).read()

        if IS_MOCK:
            HTTPretty.enable()
            cls.mock_api()

        cls.image_obj = Image._json_to_obj(cls.raw_image_str)
        cls.images_obj = Image._json_to_obj(cls.raw_images_str)

        cls.images_client = ImagesClient(
            base_url='http://localhost/v2',
            auth_token='36a04b4e71484ab9aacb1d0ac95733fc',
            serialize_format='json',
            deserialize_format='json')
Esempio n. 2
0
    def test_serialization_to_json(self):
        # Required due to datetime parser in image client
        setattr(self.image_obj, 'created_at', '2013-05-22T14:24:36Z')
        setattr(self.image_obj, 'updated_at', '2013-05-22T14:24:36Z')
        serialized_obj = self.image_obj._obj_to_json()
        # we do this to overcome the property ordering:
        deserialized_obj = Image._json_to_obj(serialized_obj)

        assert set(self.image_obj.__dict__) == set(deserialized_obj.__dict__)
Esempio n. 3
0
    def test_serialization_to_json(self):
        # Required due to datetime parser in image client
        setattr(self.image_obj, 'created_at', '2013-05-22T14:24:36Z')
        setattr(self.image_obj, 'updated_at', '2013-05-22T14:24:36Z')
        serialized_obj = self.image_obj._obj_to_json()
        # we do this to overcome the property ordering:
        deserialized_obj = Image._json_to_obj(serialized_obj)

        assert set(self.image_obj.__dict__) == set(deserialized_obj.__dict__)
Esempio n. 4
0
    def setup_class(cls):
        cls.raw_image_str = open(os.path.join(
            os.path.dirname(__file__), 'data/image.json')).read()
        cls.raw_images_str = open(os.path.join(
            os.path.dirname(__file__), 'data/images.json')).read()

        cls.raw_images_schema_str = open(os.path.join(
            os.path.dirname(__file__), 'data/images_schema.json')).read()
        cls.raw_image_schema_str = open(os.path.join(
            os.path.dirname(__file__), 'data/image_schema.json')).read()

        if IS_MOCK:
            HTTPretty.enable()
            cls.mock_api()

        cls.image_obj = Image._json_to_obj(cls.raw_image_str)
        cls.images_obj = Image._json_to_obj(cls.raw_images_str)

        cls.images_client = ImagesClient(
            base_url='http://localhost/v2',
            auth_token='36a04b4e71484ab9aacb1d0ac95733fc',
            serialize_format='json',
            deserialize_format='json'
        )
Esempio n. 5
0
    def test_serialization_to_json(self):
        serialized_obj = self.image_obj._obj_to_json()
        # we do this to overcome the property ordering:
        deserialized_obj = Image._json_to_obj(serialized_obj)

        assert set(self.image_obj.__dict__) == set(deserialized_obj.__dict__)
Esempio n. 6
0
    def test_deserialization_from_json(self):
        deserialized_obj = Image._json_to_obj(self.raw_image_str)

        assert self.image_obj == deserialized_obj