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
示例#2
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"
            )
        },
    ]
示例#3
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,
        )
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")
        },
    ]
示例#5
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")
        },
    ]