コード例 #1
0
    def setUp(self):
        self.api = AnnotationsApi()  # noqa: E501
        self.team_api = TeamsApi()
        self.image_sets_api = ImageSetsApi()
        self.product_api = ProductsApi()
        self.anno_type_api = AnnotationTypesApi()
        self.image_api = ImagesApi()

        # create dummy team, image_sets, product, image and anno_type
        teams = self.team_api.list_teams(name="test_annotation")
        if teams.count == 0:
            team = Team(name="test_annotation")
            team = self.team_api.create_team(body=team) 
        else:
            team = teams.results[0]

        image_sets = self.image_sets_api.list_image_sets(name="test_annotation")
        if image_sets.count == 0:
            image_set = ImageSet(name="test_annotation", team=team.id)
            image_set = self.image_sets_api.create_image_set(body=image_set)
        else:
            image_set = image_sets.results[0]

        products = self.product_api.list_products(name="test_annotation")
        if products.count == 0:
            product = Product(name="test_annotation", imagesets=[image_set.id], team=team.id)
            product = self.product_api.create_product(body=product)
        else:
            product = products.results[0]

        annotation_types = self.anno_type_api.list_annotation_types(name="test_annotation")
        if annotation_types.count == 0:
            annotation_type = AnnotationType(name="test_annotation", vector_type=int(AnnotationType.VECTOR_TYPE.BOUNDING_BOX), product=product.id)
            annotation_type = self.anno_type_api.create_annotation_type(body=annotation_type)
        else:
            annotation_type = annotation_types.results[0]

        images = self.image_api.list_images(name="Eosinophile.png")
        if images.count == 0:
            file_path = "exact_sync/v1/test/images/Eosinophile.png"
            image_type = 0
            
            images = self.image_api.create_image(file_path=file_path, image_type=image_type, image_set=image_set.id)
            image = images.results[0]
        else:
            image = images.results[0]

        self.team = team
        self.image_set = image_set 
        self.product = product 
        self.annotation_type = annotation_type
        self.image = image
コード例 #2
0
ファイル: exact.py プロジェクト: medical-projects/SlideRunner
 def __init__(self, client):
     self.image_sets_api = ImageSetsApi(client)
     self.annotations_api = AnnotationsApi(client)
     self.annotation_types_api = AnnotationTypesApi(client)
     self.images_api = ImagesApi(client)
     self.product_api = ProductsApi(client)
     self.team_api = TeamsApi(client)
     self.users_api = UsersApi(client)
コード例 #3
0
    def setUp(self):
        self.api = ImagesApi()  # noqa: E501
        self.team_api = TeamsApi()
        self.image_sets_api = ImageSetsApi()

        # create dummy team and image_sets
        teams = self.team_api.list_teams(name="test_images")
        if teams.count == 0:
            team = Team(name="test_images")
            team = self.team_api.create_team(body=team)
        else:
            team = teams.results[0]

        image_sets = self.image_sets_api.list_image_sets(name="test_images")
        if image_sets.count == 0:
            image_set = ImageSet(name="test_images", team=team.id)
            image_set = self.image_sets_api.create_image_set(body=image_set)
        else:
            image_set = image_sets.results[0]

        self.team = team
        self.image_set = image_set
コード例 #4
0
class TestImagesApi(unittest.TestCase):
    """ImagesApi unit test stubs"""
    def setUp(self):
        self.api = ImagesApi()  # noqa: E501
        self.team_api = TeamsApi()
        self.image_sets_api = ImageSetsApi()

        # create dummy team and image_sets
        teams = self.team_api.list_teams(name="test_images")
        if teams.count == 0:
            team = Team(name="test_images")
            team = self.team_api.create_team(body=team)
        else:
            team = teams.results[0]

        image_sets = self.image_sets_api.list_image_sets(name="test_images")
        if image_sets.count == 0:
            image_set = ImageSet(name="test_images", team=team.id)
            image_set = self.image_sets_api.create_image_set(body=image_set)
        else:
            image_set = image_sets.results[0]

        self.team = team
        self.image_set = image_set

    def tearDown(self):

        self.image_sets_api.destroy_image_set(id=self.image_set.id)
        self.team_api.destroy_team(id=self.team.id)
        pass

    def test_create_image(self):
        """Test case for create_image

        """
        file_path = "exact_sync/v1/test/images/Eosinophile.png"
        image_type = 0
        image_set = self.image_set.id
        created_images = self.api.create_image(file_path=file_path,
                                               image_type=image_type,
                                               image_set=image_set)

        for image in created_images.results:
            self.api.destroy_image(id=image.id)
        pass

    def test_destroy_image(self):
        """Test case for destroy_image tested with test_create_image

        """

        pass

    def test_list_images(self):
        """Test case for list_images

        """
        images = self.api.list_images(omit="annotations")
        pass

    def test_partial_update_image(self):
        """Test case for partial_update_image

        """
        file_path = "exact_sync/v1/test/images/Eosinophile.png"
        image_type = 0
        image_set = self.image_set.id
        created_images = self.api.create_image(file_path=file_path,
                                               image_type=image_type,
                                               image_set=image_set)

        for image in created_images.results:
            objective_power = 40
            updated_image = self.api.partial_update_image(
                id=image.id, objective_power=objective_power)

            assert updated_image.objective_power == objective_power
            self.api.destroy_image(id=image.id)

    def test_retrieve_image(self):
        """Test case for retrieve_image

        """
        images = self.api.list_images(omit="annotations")
        image = images.results[0]
        image = self.api.retrieve_image(id=image.id)
        pass

    def test_update_image(self):
        """Test case for update_image

        """
        assert False
コード例 #5
0
class TestAnnotationsApi(unittest.TestCase):
    """AnnotationsApi unit test stubs"""

    def setUp(self):
        self.api = AnnotationsApi()  # noqa: E501
        self.team_api = TeamsApi()
        self.image_sets_api = ImageSetsApi()
        self.product_api = ProductsApi()
        self.anno_type_api = AnnotationTypesApi()
        self.image_api = ImagesApi()

        # create dummy team, image_sets, product, image and anno_type
        teams = self.team_api.list_teams(name="test_annotation")
        if teams.count == 0:
            team = Team(name="test_annotation")
            team = self.team_api.create_team(body=team) 
        else:
            team = teams.results[0]

        image_sets = self.image_sets_api.list_image_sets(name="test_annotation")
        if image_sets.count == 0:
            image_set = ImageSet(name="test_annotation", team=team.id)
            image_set = self.image_sets_api.create_image_set(body=image_set)
        else:
            image_set = image_sets.results[0]

        products = self.product_api.list_products(name="test_annotation")
        if products.count == 0:
            product = Product(name="test_annotation", imagesets=[image_set.id], team=team.id)
            product = self.product_api.create_product(body=product)
        else:
            product = products.results[0]

        annotation_types = self.anno_type_api.list_annotation_types(name="test_annotation")
        if annotation_types.count == 0:
            annotation_type = AnnotationType(name="test_annotation", vector_type=int(AnnotationType.VECTOR_TYPE.BOUNDING_BOX), product=product.id)
            annotation_type = self.anno_type_api.create_annotation_type(body=annotation_type)
        else:
            annotation_type = annotation_types.results[0]

        images = self.image_api.list_images(name="Eosinophile.png")
        if images.count == 0:
            file_path = "exact_sync/v1/test/images/Eosinophile.png"
            image_type = 0
            
            images = self.image_api.create_image(file_path=file_path, image_type=image_type, image_set=image_set.id)
            image = images.results[0]
        else:
            image = images.results[0]

        self.team = team
        self.image_set = image_set 
        self.product = product 
        self.annotation_type = annotation_type
        self.image = image

    def tearDown(self):

        self.image_api.destroy_image(id=self.image.id)
        self.anno_type_api.destroy_annotation_type(id=self.annotation_type.id)
        self.product_api.destroy_product(id=self.product.id)
        self.image_sets_api.destroy_image_set(id=self.image_set.id)
        self.team_api.destroy_team(id=self.team.id)

        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.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

        """
        assert False

    def test_list_annotations(self):
        """Test case for list_annotations

        """
        annotations = self.api.list_annotations(omit="annotation_types")
        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.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)
        
        new_vector = {"x1":100, "x2":200, "y1":100, "y2":200}
        updated_annotation = self.api.partial_update_annotation(id=created_annotation.id, last_edit_time=last_edit_time, vector=new_vector)
        
        assert new_vector == updated_annotation.vector
        assert last_edit_time == updated_annotation.last_edit_time
        self.api.destroy_annotation(id=created_annotation.id)

    def test_retrieve_annotation(self):
        
        """Test case for retrieve_annotation

        """
        annotations = self.api.list_annotations(omit="annotation_types")
        anno = annotations.results[0]
        annotation = self.api.retrieve_annotation(id=anno.id)
        pass

    def test_update_annotation(self):
        
        """Test case for update_annotation

        """
        vector = {"x1":10, "x2":20, "y1":10, "y2":20}
        unique_identifier = str(uuid.uuid4())
        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)
        
        created_annotation.deleted = True
        updated_annotation = self.api.update_annotation(id=created_annotation.id, body=created_annotation)
        
        assert created_annotation.deleted == updated_annotation.deleted
        self.api.destroy_annotation(id=created_annotation.id)
コード例 #6
0
class TestAnnotationMediaFilesApi(unittest.TestCase):
    """AnnotationMediaFilesApi unit test stubs"""

    def setUp(self):
        self.api = AnnotationMediaFilesApi()  # noqa: E501
        self.team_api = TeamsApi()
        self.image_sets_api = ImageSetsApi()
        self.product_api = ProductsApi()
        self.anno_type_api = AnnotationTypesApi()
        self.image_api = ImagesApi()
        self.annotations_api = AnnotationsApi()

        # create dummy team, image_sets, product, image, anno_type and annotation
        teams = self.team_api.list_teams(name="test_annotation")
        if teams.count == 0:
            team = Team(name="test_annotation")
            team = self.team_api.create_team(body=team) 
        else:
            team = teams.results[0]

        image_sets = self.image_sets_api.list_image_sets(name="test_annotation")
        if image_sets.count == 0:
            image_set = ImageSet(name="test_annotation", team=team.id)
            image_set = self.image_sets_api.create_image_set(body=image_set)
        else:
            image_set = image_sets.results[0]

        products = self.product_api.list_products(name="test_annotation")
        if products.count == 0:
            product = Product(name="test_annotation", imagesets=[image_set.id], team=team.id)
            product = self.product_api.create_product(body=product)
        else:
            product = products.results[0]

        annotation_types = self.anno_type_api.list_annotation_types(name="test_annotation")
        if annotation_types.count == 0:
            annotation_type = AnnotationType(name="test_annotation", vector_type=int(AnnotationType.VECTOR_TYPE.BOUNDING_BOX), product=product.id)
            annotation_type = self.anno_type_api.create_annotation_type(body=annotation_type)
        else:
            annotation_type = annotation_types.results[0]

        images = self.image_api.list_images(name="Eosinophile.png")
        if images.count == 0:
            file_path = "exact_sync/v1/test/images/Eosinophile.png"
            image_type = 0
            
            images = self.image_api.create_image(file_path=file_path, image_type=image_type, image_set=image_set.id)
            image = images.results[0]
        else:
            image = images.results[0]

        annotations = self.annotations_api.list_annotations(image=image.id)
        if annotations.count == 0:
            vector = {"x1":10, "x2":20, "y1":10, "y2":20}
            annotation = Annotation(annotation_type=annotation_type.id, vector=vector, image=image.id)
            annotation = self.annotations_api.create_annotation(body=annotation)
        else:
            annotation = annotations.results[0]

        self.team = team
        self.image_set = image_set 
        self.product = product 
        self.annotation_type = annotation_type
        self.image = image
        self.annotation = annotation


    def tearDown(self):

        self.annotations_api.destroy_annotation(id=self.annotation.id)
        self.image_api.destroy_image(id=self.image.id)
        self.anno_type_api.destroy_annotation_type(id=self.annotation_type.id)
        self.product_api.destroy_product(id=self.product.id)
        self.image_sets_api.destroy_image_set(id=self.image_set.id)
        self.team_api.destroy_team(id=self.team.id)

        pass

    def test_create_annotation_media_file(self):
        """Test case for create_annotation_media_file

        """
        file = "exact_sync/v1/test/images/sound.wav"
        name = "c_annotation_media_file"
        media_file_type = 4
        created_media_files = self.api.create_annotation_media_file(name=name, file=file, media_file_type=media_file_type, annotation=self.annotation.id)

        for media_file in created_media_files.results:

            new_name = "123.wav"
            updated = self.api.partial_update_annotation_media_file(id=media_file.id, name=new_name)
            
            assert new_name == updated.name
            self.api.destroy_annotation_media_file(id=media_file.id)

    def test_destroy_annotation_media_file(self):
        """Test case for destroy_annotation_media_file

        """
        assert False

    def test_list_annotation_media_files(self):
        """Test case for list_annotation_media_files

        """
        annotation_media_files = self.api.list_annotation_media_files()
        pass

    def test_partial_update_annotation_media_file(self):
        """Test case for partial_update_annotation_media_file

        """
        assert False

    def test_retrieve_annotation_media_file(self):
        """Test case for retrieve_annotation_media_file

        """
        annotation_media_files = self.api.list_annotation_media_files()
        media = annotation_media_files.results[0]
        annotation_media_file = self.api.retrieve_annotation_media_file(id=media.id)
        pass

    def test_update_annotation_media_file(self):
        """Test case for update_annotation_media_file

        """
        assert False