def testStoreObjectInGCS_NotResizableMimeType(self):
        guid = 'aaaaa'
        project_id = 100
        object_id = '/%s/attachments/%s' % (project_id, guid)
        bucket_name = 'test_bucket'
        object_path = '/' + bucket_name + object_id
        mime_type = 'not_resizable_mime_type'
        content = 'content'

        self.mox.StubOutWithMock(app_identity, 'get_default_gcs_bucket_name')
        app_identity.get_default_gcs_bucket_name().AndReturn(bucket_name)

        self.mox.StubOutWithMock(uuid, 'uuid4')
        uuid.uuid4().AndReturn(guid)

        self.mox.StubOutWithMock(cloudstorage, 'open')
        cloudstorage.open(object_path, 'w',
                          mime_type).AndReturn(fake.FakeFile())

        self.mox.ReplayAll()

        ret_id = gcs_helpers.StoreObjectInGCS(content, mime_type, project_id,
                                              gcs_helpers.DEFAULT_THUMB_WIDTH,
                                              gcs_helpers.DEFAULT_THUMB_HEIGHT)
        self.mox.VerifyAll()
        self.assertEquals(object_id, ret_id)
    def testStoreLogoInGCS(self):
        file_name = 'test_file.png'
        mime_type = 'image/png'
        content = 'test content'
        project_id = 100
        object_id = 123

        self.mox.StubOutWithMock(filecontent, 'GuessContentTypeFromFilename')
        filecontent.GuessContentTypeFromFilename(file_name).AndReturn(
            mime_type)

        self.mox.StubOutWithMock(gcs_helpers, 'StoreObjectInGCS')
        gcs_helpers.StoreObjectInGCS(
            content,
            mime_type,
            project_id,
            thumb_width=gcs_helpers.LOGO_THUMB_WIDTH,
            thumb_height=gcs_helpers.LOGO_THUMB_HEIGHT).AndReturn(object_id)

        self.mox.ReplayAll()

        ret_id = gcs_helpers.StoreLogoInGCS(file_name, content, project_id)
        self.mox.VerifyAll()
        self.assertEquals(object_id, ret_id)