예제 #1
0
class TestDataSchemas(MockApiTest, ObjectTest):

    base_url = "/v1/datasets/{dataset.ext_id}/schemas"
    obj_key = "dataschema"
    obj_create_data = {"data": {"foo": "bar"}}
    obj_update_data = {"data": {"bar": "bam"}}

    fixtures = [
        {
            "auth_client": auth_client
        },
        {
            "organization": organization
        },
        {
            "user": user
        },
        {
            "project": project
        },
        {
            "dataset": dataset
        },
        {
            "dataschema": dataschema
        },
        {
            "dataset_dataschema": dataset_dataschema
        },
        {
            "object_role":
            lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project")
        },
    ]
예제 #2
0
class TestAlgorithmSchemas(MockApiTest, ObjectTest):

    base_url = "/v1/algorithms/{algorithm.ext_id}/schemas"
    obj_key = "algorithmschema"
    obj_create_data = {"data": {"foo": "bar"}}
    obj_update_data = {"data": {"bar": "bam"}}

    fixtures = [
        {"auth_client": auth_client},
        {"organization": organization},
        {"user": user},
        {"project": lambda test, fixtures: project(test, fixtures, "example")},
        {"algorithm": lambda test, fixtures: algorithm(test, fixtures, "project")},
        {"algorithmschema": lambda test, fixtures: algorithmschema(test, fixtures)},
        {
            "algorithm_algorithmschema": lambda test, fixtures: algorithm_algorithmschema(
                test, fixtures, algorithm="algorithm", algoschema="algorithmschema"
            )
        },
        {
            "object_role": lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project"
            )
        },
    ]
class TestDatasetModelResults(MockApiTest, ObjectTest):

    obj_key = "dataset_model_result"
    obj_create_data = {"data": {"foo": "bar"}, "name": "test"}
    obj_update_data = {"data": {"bar": "bam"}, "name": "bar"}

    fixtures = [
        {
            "auth_client": auth_client
        },
        {
            "organization": organization
        },
        {
            "user": user
        },
        {
            "project":
            lambda test, fixtures: project(test, fixtures, "example")
        },
        {
            "algorithm":
            lambda test, fixtures: algorithm(test, fixtures, "project")
        },
        {
            "dataset":
            lambda test, fixtures: dataset(test, fixtures, name="foo/bar")
        },
        {
            "model": model
        },
        {
            "dataset_model_result": dataset_model_result
        },
        {
            "object_role":
            lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project")
        },
    ]

    @property
    def url(self):
        model = self.model
        return "/v1/models/{}/datasetresults".format(model.ext_id)

    @property
    def list_url(self):
        ds = self.dataset
        model = self.model
        return "/v1/datasets/{}/models/{}/results".format(
            ds.ext_id, model.ext_id)

    @property
    def create_url(self):
        return self.list_url
예제 #4
0
class TestProjects(MockApiTest, ObjectTest):

    base_url = "/v1/projects"

    obj_key = "project"
    obj_create_data = {
        "path": "example/project",
        "name": "test",
        "data": {"foo": "bar"},
        "description": "",
        "tags": ["my", "tags"],
    }
    obj_update_data = {
        "path": "another/path",
        "name": "another test",
        "data": {"bar": "baz"},
        "description": "foo",
        "tags": ["one", "two"],
    }

    @property
    def create_url(self):
        return "v1/organizations/{}/projects".format(self.organization.source_id.hex())

    fixtures = [
        {"auth_client": auth_client},
        {"organization": organization},
        {
            "another_organization": lambda test, fixtures: organization(
                test, fixtures, name="another one"
            )
        },
        {"user": user},
        {"project": lambda test, fixtures: project(test, fixtures, "example")},
        # the next project is not visible to the user
        {
            "another_project": lambda test, fixtures: project(
                test, fixtures, "another_example", "another_organization"
            )
        },
        {
            "object_role": lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project"
            )
        },
    ]
예제 #5
0
class TestDatasetResults(MockApiTest, ObjectTest):

    base_url = "/v1/datasets/{dataset.ext_id}/results"
    obj_key = "dataset_result"
    obj_create_data = {"data": {"foo": "bar"}, "name": "test"}
    obj_update_data = {"data": {"bar": "bam"}, "name": "bar"}

    fixtures = [
        {"auth_client": auth_client},
        {"organization": organization},
        {"user": user},
        {"project": lambda test, fixtures: project(test, fixtures, "example")},
        {"dataset": lambda test, fixtures: dataset(test, fixtures, name="foo/bar")},
        {"dataset_result": dataset_result},
        {
            "object_role": lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project"
            )
        },
    ]
예제 #6
0
class TestAlgorithmResults(MockApiTest, ObjectTest):

    base_url = "/v1/algorithms/{algorithm.ext_id}/results"
    obj_key = "algorithm_result"
    obj_create_data = {"data": {"foo": "bars"}, "name": "another test"}
    obj_update_data = {"data": {"bar": "bam"}, "name": "bar"}

    fixtures = [
        {
            "auth_client": auth_client
        },
        {
            "organization": organization
        },
        {
            "user": user
        },
        {
            "project":
            lambda test, fixtures: project(test, fixtures, "example")
        },
        {
            "algorithm":
            lambda test, fixtures: algorithm(test, fixtures, "project")
        },
        {
            "dataset":
            lambda test, fixtures: dataset(test, fixtures, name="foo/bar")
        },
        {
            "model": model
        },
        {
            "algorithm_result": algorithm_result
        },
        {
            "object_role":
            lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project")
        },
    ]
예제 #7
0
class TestAlgorithmModels(MockApiTest, ObjectTest):

    base_url = "/v1/models"
    obj_key = "model"
    obj_create_data = {"data": {"foo": "bar"}}
    obj_update_data = {"data": {"bar": "bam"}}

    @property
    def list_url(self):
        return "/v1/algorithms/{}/models".format(self.algorithm.ext_id)

    @property
    def create_url(self):
        return "/v1/datasets/{}/algorithms/{}/models".format(
            self.dataset.ext_id, self.algorithm.ext_id
        )

    fixtures = [
        {"auth_client": auth_client},
        {"organization": organization},
        {"user": user},
        {"project": lambda test, fixtures: project(test, fixtures, "example")},
        {"algorithm": lambda test, fixtures: algorithm(test, fixtures, "project")},
        {"dataset": lambda test, fixtures: dataset(test, fixtures, name="foo/bar")},
        {"model": model},
        {"model_result": model_result},
        {
            "object_role": lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project"
            )
        },
    ]

    def _create(self, data):
        ds = self.dataset
        av = self.algorithm
        return self.app.post(
            "/v1/datasets/{}/algorithms/{}/models".format(ds.ext_id, av.ext_id),
            headers={"Authorization": "bearer test"},
            json=data,
        )
예제 #8
0
class Tests(MockApiTest, ObjectTest):

    base_url = "/v1/algorithms"
    obj_key = "algorithm"
    obj_create_data = {"data": {"foo": "bar"}, "name": "test"}
    obj_update_data = {"data": {"bar": "bam"}, "name": "foo"}

    @property
    def list_url(self):
        return "/v1/projects/{}/algorithms".format(self.project.ext_id)

    @property
    def create_url(self):
        return self.list_url

    fixtures = [
        {
            "auth_client": auth_client
        },
        {
            "organization": organization
        },
        {
            "user": user
        },
        {
            "project":
            lambda test, fixtures: project(test, fixtures, "example")
        },
        {
            "algorithm":
            lambda test, fixtures: algorithm(test, fixtures, "project")
        },
        {
            "object_role":
            lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project")
        },
    ]
예제 #9
0
class TestDatasets(MockApiTest, ObjectTest):

    base_url = "/v1/datasets"
    obj_key = "dataset"
    obj_create_data = {
        "name": "example/algo",
        "data": {
            "foo": "bar"
        },
        "tags": ["my", "tags"],
    }
    obj_update_data = {
        "name": "another/path",
        "data": {
            "bar": "baz"
        },
        "tags": ["one", "two"],
    }

    @property
    def list_url(self):
        return "/v1/projects/{}/datasets".format(self.project.ext_id)

    @property
    def create_url(self):
        return self.list_url

    fixtures = [
        {
            "auth_client": auth_client
        },
        {
            "organization": organization
        },
        {
            "another_organization":
            lambda test, fixtures: organization(
                test, fixtures, name="another one")
        },
        {
            "user": user
        },
        {
            "project": project
        },
        {
            "another_project":
            lambda test, fixtures: project(test, fixtures, "another/project",
                                           "another_organization")
        },
        {
            "dataset":
            lambda test, fixtures: dataset(test, fixtures, "example")
        },
        # the next dataset is not visible to the user
        {
            "another_dataset":
            lambda test, fixtures: dataset(test, fixtures, "another_example",
                                           "another_project")
        },
        {
            "object_role":
            lambda test, fixtures: object_role(
                test, fixtures, "admin", "admin", "organization", "project")
        },
    ]