Skip to content

Commit

Permalink
Added bulk create support
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Marzahl committed Sep 15, 2020
1 parent 61641d1 commit 38ec837
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
6 changes: 5 additions & 1 deletion exact_sync/v1/api/annotations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ def create_annotation_with_http_info(self, **kwargs): # noqa: E501
form_params = []
local_var_files = {}

response_type = 'Annotation'
if isinstance(params['body'], list):
response_type = "list[Annotation]"

body_params = {}
if 'body' in params:
body_params = params['body']
Expand All @@ -117,7 +121,7 @@ def create_annotation_with_http_info(self, **kwargs): # noqa: E501
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='Annotation', # noqa: E501
response_type=response_type, # noqa: E501
auth_settings=auth_settings,
async_req=params.get('async_req'),
_return_http_data_only=params.get('_return_http_data_only'),
Expand Down
19 changes: 17 additions & 2 deletions exact_sync/v1/test/test_annotations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import unittest
import uuid
import datetime

from exact_sync.v1.api_client import ApiClient as client

Expand Down Expand Up @@ -96,19 +97,30 @@ def tearDown(self):
pass

def test_create_annotation(self):

"""Test case for create_annotation
"""
vector = {"x1":10, "x2":20, "y1":10, "y2":20}
unique_identifier = str(uuid.uuid4())
time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")
time = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")
annotation = Annotation(annotation_type=self.annotation_type.id, time=time, vector=vector, image=self.image.id, unique_identifier=unique_identifier)
created_annotation = self.api.create_annotation(body=annotation)

assert created_annotation.unique_identifier == unique_identifier
assert created_annotation.time == time
self.api.destroy_annotation(id=created_annotation.id)


def test_create_annotation_list(self):
"""Test case for create_annotation
"""
vector = {"x1":10, "x2":20, "y1":10, "y2":20}
annotations = [Annotation(annotation_type=self.annotation_type.id, vector=vector, image=self.image.id)
for i in range(10)]
created_annotations = self.api.create_annotation(body=annotations)

def test_destroy_annotation(self):
"""Test case for destroy_annotation
Expand All @@ -123,12 +135,13 @@ def test_list_annotations(self):
pass

def test_partial_update_annotation(self):

"""Test case for partial_update_annotation
"""
vector = {"x1":10, "x2":20, "y1":10, "y2":20}
unique_identifier = str(uuid.uuid4())
last_edit_time = datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")
last_edit_time = datetime.datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%f")

annotation = Annotation(annotation_type=self.annotation_type.id, vector=vector, image=self.image.id, unique_identifier=unique_identifier)
created_annotation = self.api.create_annotation(body=annotation)
Expand All @@ -141,6 +154,7 @@ def test_partial_update_annotation(self):
self.api.destroy_annotation(id=created_annotation.id)

def test_retrieve_annotation(self):

"""Test case for retrieve_annotation
"""
Expand All @@ -150,6 +164,7 @@ def test_retrieve_annotation(self):
pass

def test_update_annotation(self):

"""Test case for update_annotation
"""
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

setuptools.setup(
name="EXCAT-Sync",
version="0.0.18",
version="0.0.19",
author="Christian Marzahl",
author_email="christian.marzahl(at)gmail.com",
author_email="christian.marzahl@gamil.com",
description="A package to download images and annotations from the EXACT Server https://github.com/ChristianMarzahl/Exact",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down

0 comments on commit 38ec837

Please sign in to comment.