Esempio n. 1
0
    def test_get_image_data_too_eraly(self):
        self.image.status = 'queued'
        images._fetch_image('IMG', to_modify=False).AndReturn(self.image)

        self.mox.ReplayAll()
        rv = self.client.get('/v1/images/IMG/data')
        self.check_and_parse_response(rv, status_code=405)
Esempio n. 2
0
    def test_get_image_data_too_eraly(self):
        self.image.status = "queued"
        images._fetch_image("IMG", to_modify=False).AndReturn(self.image)

        self.mox.ReplayAll()
        rv = self.client.get("/v1/images/IMG/data")
        self.check_and_parse_response(rv, status_code=405)
Esempio n. 3
0
    def test_get_image_data_late_404(self):
        images._fetch_image('IMG', to_modify=False).AndReturn(self.image)
        self.image.data().AndRaise(osc_exc.NotFound('gone'))

        self.mox.ReplayAll()
        rv = self.client.get('/v1/images/IMG/data')
        self.check_and_parse_response(rv, status_code=404)
Esempio n. 4
0
    def test_get_image_data_late_404(self):
        images._fetch_image("IMG", to_modify=False).AndReturn(self.image)
        self.image.data().AndRaise(osc_exc.NotFound("gone"))

        self.mox.ReplayAll()
        rv = self.client.get("/v1/images/IMG/data")
        self.check_and_parse_response(rv, status_code=404)
Esempio n. 5
0
    def test_update_image_name(self):
        image = doubles.make(self.mox, doubles.Image, id=u"IMAGE", owner=u"PID")

        images._fetch_image(image.id, to_modify=True).AndReturn(image)
        image.update(name="UPDATED")
        images._fetch_image(image.id, to_modify=False).AndReturn("UPDATED IMAGE")
        images._image_to_view("UPDATED IMAGE").AndReturn("REPLY")

        self.mox.ReplayAll()
        data = self.interact(image.id, {"name": "UPDATED"})
        self.assertEquals(data, "REPLY")
Esempio n. 6
0
    def test_get_image_data_works(self):
        data = 'a' * 42
        images._fetch_image('IMG', to_modify=False).AndReturn(self.image)
        self.image.data().AndReturn(data)

        self.mox.ReplayAll()
        rv = self.client.get('/v1/images/IMG/data')
        self.assertEquals(rv.status_code, 200)
        self.assertTrue('X-GD-Altai-Implementation' in rv.headers)
        self.assertEquals(rv.content_length, 42)
        self.assertEquals(rv.content_type, 'application/octet-stream')
        self.assertEquals(rv.data, data)
Esempio n. 7
0
    def test_get_image_data_works(self):
        data = "a" * 42
        images._fetch_image("IMG", to_modify=False).AndReturn(self.image)
        self.image.data().AndReturn(data)

        self.mox.ReplayAll()
        rv = self.client.get("/v1/images/IMG/data")
        self.assertEquals(rv.status_code, 200)
        self.assertTrue("X-GD-Altai-Implementation" in rv.headers)
        self.assertEquals(rv.content_length, 42)
        self.assertEquals(rv.content_type, "application/octet-stream")
        self.assertEquals(rv.data, data)
Esempio n. 8
0
    def test_update_image_name(self):
        image = doubles.make(self.mox, doubles.Image,
                             id=u'IMAGE', owner=u'PID')

        images._fetch_image(image.id, to_modify=True).AndReturn(image)
        image.update(name='UPDATED')
        images._fetch_image(image.id, to_modify=False)\
                .AndReturn('UPDATED IMAGE')
        images._image_to_view('UPDATED IMAGE').AndReturn('REPLY')

        self.mox.ReplayAll()
        data = self.interact(image.id, {'name': 'UPDATED'})
        self.assertEquals(data, 'REPLY')