示例#1
0
    def test_get_image(self):
        images_factory = ImagesFactory(http_client=self._http_client, images_url=self.get_url('/alpha/images'))
        image_body = images_factory.create_image_body()
        response = images_factory.create_image()

        url = loads(response.body)['url']
        path = '/' + ('/').join(url.split('/')[3:])
        response = self._http_client.get(path)

        assert response.code == 200
        assert 'image/jpeg' in response.headers['Content-Type']
        assert response.body == image_body
示例#2
0
    def test_get_image(self):
        images_factory = ImagesFactory(
            http_client=self._http_client,
            images_url=self.get_url('/alpha/images'))
        image_body = images_factory.create_image_body()
        response = images_factory.create_image()

        url = loads(response.body)['url']
        path = '/' + ('/').join(url.split('/')[3:])
        response = self._http_client.get(path)

        assert response.code == 200
        assert 'image/jpeg' in response.headers['Content-Type']
        assert response.body == image_body
示例#3
0
    def test_post_images(self):
        images_factory = ImagesFactory(http_client=self._http_client, images_url=self.get_url('/alpha/images'))
        response = images_factory.create_image()

        assert response.code == 201
        assert 'application/json' in response.headers['Content-Type']
        body = loads(response.body)
        assert body['title'] == u'Title'
        assert body['credits'] == u'Créditos'
        assert body['tags'] == [u'tag1', u'tag2']
        assert body['eventDate'] == u'2012-10-08T17:02:00'
        assert isinstance(dateutil.parser.parse(body['createdDate']), datetime)
        self.assertRegexpMatches(body['url'], r'http://localhost:\d+/alpha/images/.+/image\.jpeg')
        assert body['width'] == 134
        assert body['height'] == 84
示例#4
0
 def setUp(self):
     super(GetImagesTestCase, self).setUp()
     images_factory = ImagesFactory(http_client=self._http_client, images_url=self.get_url('/alpha/images'))
     images_factory.create_image()
     self._elastic_search_for_test.refresh()