def test_delete_visions_tags(self): """Test case for delete_visions_tags Delete a sample's tag based the tag name # noqa: E501 """ # delete existent sample tag photo_dir = 'files/' body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name photo_path = photo_dir + photo_name ret = self.api_instance.get_visions_photos(body=photo_name, _preload_content=False) self.assertEqual(ret.status, 200, ret) with open(photo_path, 'wb') as fwrite: fwrite.write(ret.data) # ret.data is binary data of photo ret = self.api_instance.post_visions_photo_samples(file=photo_path) self.assertEqual(ret.code, 0, ret) tags = str(int(time.time())) body = VisionsPutTags(tags=tags, resources=[photo_name]) ret = self.api_instance.put_visions_tags(body=body) self.assertEqual(ret.code, 0, ret) body = VisionsDeleteTags(tags=tags) ret = self.api_instance.delete_visions_tags(body=body) self.assertEqual(ret.code, 0, ret) # delete deleted sample tag body = VisionsDeleteTags(tags=tags) ret = self.api_instance.delete_visions_tags(body=body) self.assertEqual(ret.code, 0, ret)
def test_put_visions_tags(self): """Test case for put_visions_tags Set the sample's tag # noqa: E501 """ photo_dir = 'files/' # take a photo body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name photo_path = photo_dir + photo_name # get specific photo ret = self.api_instance.get_visions_photos(body=photo_name, _preload_content=False) self.assertEqual(ret.status, 200, ret) with open(photo_path, 'wb') as fwrite: fwrite.write(ret.data) # ret.data is binary data of photo # upload photo sample ret = self.api_instance.post_visions_photo_samples(file=photo_path) self.assertEqual(ret.code, 0, ret) # set sample tag body = VisionsPutTags(tags=str(int(time.time())), resources=[photo_name]) ret = self.api_instance.put_visions_tags(body=body) self.assertEqual(ret.code, 0, ret)
def test_delete_vision_photo_samples(self): """Test case for delete_vision_photo_samples Delete the uploaded sample # noqa: E501 """ # delete existent sample photo_dir = 'files/' body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name photo_path = photo_dir + photo_name ret = self.api_instance.get_visions_photos(body=photo_name, _preload_content=False) self.assertEqual(ret.status, 200, ret) with open(photo_path, 'wb') as fwrite: fwrite.write(ret.data) # ret.data is binary data of photo ret = self.api_instance.post_visions_photo_samples(file=photo_path) self.assertEqual(ret.code, 0, ret) body = Name(name=photo_name) ret = self.api_instance.delete_vision_photo_samples(body=body) self.assertEqual(ret.code, 0, ret) # delete deleted sample body = Name(name=photo_name) ret = self.api_instance.delete_vision_photo_samples(body=body) self.assertEqual(ret.code, 0, ret)
def test_get_photo_samples(self): """Test case for get_photo_samples Get all the uploaded photo samples # noqa: E501 """ photo_dir = 'files/' # take a photo body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name photo_path = photo_dir + photo_name # get specific photo ret = self.api_instance.get_visions_photos(body=photo_name, _preload_content=False) self.assertEqual(ret.status, 200, ret) with open(photo_path, 'wb') as fwrite: fwrite.write(ret.data) # ret.data is binary data of photo # upload photo sample ret = self.api_instance.post_visions_photo_samples(file=photo_path) self.assertEqual(ret.code, 0, ret) # get uploaded photo samples ret = self.api_instance.get_photo_samples() # return VisionsPhotoListResponse instance self.assertEqual(ret.code, 0, ret) found = False for name in ret.data: if name.name == photo_name: found = True break self.assertEqual(found, True, ret)
def test_post_vision_photo(self): """Test case for post_vision_photo Take a photo # noqa: E501 """ body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) self.assertEqual(ret.data.name.endswith('jpg'), True, ret)
def test_delete_vision_photo(self): """Test case for delete_vision_photo Delete a photo based the name # noqa: E501 """ # delete existent photo body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) name = ret.data.name body = Name(name=name) ret = self.api_instance.delete_vision_photo(body=body) self.assertEqual(ret.code, 0, ret) # delete deleted photo body = Name(name=name) ret = self.api_instance.delete_vision_photo(body=body) self.assertEqual(ret.code, 0, ret)
def test_get_visions_photos_lists(self): """Test case for get_visions_photos_lists Get the photo's list # noqa: E501 """ # take a photo body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name # get photo list ret = self.api_instance.get_visions_photos_lists() # return VisionsPhotoListResponse instance self.assertEqual(ret.code, 0, ret) found = False for name in ret.data: if name.name == photo_name: found = True break self.assertEqual(found, True, ret)
def test_get_visions_photos(self): """Test case for get_visions_photos Get a specific photo based the name # noqa: E501 """ photo_dir = 'files/' # take a photo body = VisionsPhoto(resolution="1280x800") ret = self.api_instance.post_vision_photo(body=body) # return VisionsPhotoResponse instance self.assertEqual(ret.code, 0, ret) photo_name = ret.data.name photo_path = photo_dir + photo_name # get specific photo ret = self.api_instance.get_visions_photos(body=photo_name, _preload_content=False) self.assertEqual(ret.status, 200, ret) with open(photo_path, 'wb') as fwrite: fwrite.write(ret.data) # ret.data is binary data of photo with open(photo_path, 'rb') as fread: self.assertNotEqual(fread.read(), b'', ret)