Beispiel #1
0
 def project(self, project: Union[Project, int]) -> Project:
     project_id = self._get_object_id(project)
     response = self.client.get(f'/projects/{project_id}')
     return ProjectSchema().load(response.json()['body'], many=False)
Beispiel #2
0
 def import_project(self, zip_stream: IO) -> Project:
     response = self.client.post("/projects/import",
                                 files={"file": ('test/path', zip_stream)},
                                 allowed_statuses=(201, 200))
     return ProjectSchema().load(response.json()['body'], many=False)
Beispiel #3
0
 def projects(self) -> List[Project]:
     response = self.client.get('/projects', allowed_statuses=(200, ))
     return ProjectSchema().load(response.json()['body'], many=True)
Beispiel #4
0
def test_project_schema_load_list_of_dicts_many_true(
        project_schema: ProjectSchema, serialized_project: dict):
    assert type(project_schema.load([serialized_project],
                                    many=True)[0]) is Project
Beispiel #5
0
def project_schema():
    return ProjectSchema()
Beispiel #6
0
def test_project_schema_dump_one_dict_many_false(project_schema: ProjectSchema,
                                                 deserialized_project: Project,
                                                 serialized_project: dict):
    assert project_schema.dump(deserialized_project) == serialized_project
Beispiel #7
0
def test_project_schema_load_list_no_empty_many_true(
        project_schema: ProjectSchema, serialized_project: dict):
    assert len(project_schema.load([serialized_project], many=True)) == 1
Beispiel #8
0
def test_project_schema_load_one_dict_many_false(project_schema: ProjectSchema,
                                                 deserialized_project: Project,
                                                 serialized_project: dict):
    assert project_schema.load(serialized_project) == deserialized_project
Beispiel #9
0
def test_project_schema_load_one_dict_many_true(project_schema: ProjectSchema,
                                                deserialized_project: Project,
                                                serialized_project: dict):
    assert project_schema.load([serialized_project],
                               many=True) == [deserialized_project]
Beispiel #10
0
def test_project_schema_dump_list_of_dicts_many_true(
        project_schema: ProjectSchema, deserialized_project: Project):
    assert type(project_schema.dump([deserialized_project],
                                    many=True)[0]) is dict
Beispiel #11
0
def test_project_schema_dump_list_no_empty_many_true(
        project_schema: ProjectSchema, deserialized_project: Project):
    assert len(project_schema.dump([deserialized_project], many=True)) == 1
Beispiel #12
0
def test_project_schema_dump_one_dict_many_true(project_schema: ProjectSchema,
                                                deserialized_project: Project,
                                                serialized_project: dict):
    assert project_schema.dump([deserialized_project],
                               many=True) == [serialized_project]
Beispiel #13
0
 def create_project(self, project_name: str, creator_name: Optional[str] = None) -> Project:
     creator_name = creator_name or self.default_username
     response = self.client.post('/projects', form_data={'creator': creator_name, 'name': project_name},
                                 allowed_statuses=(201,))
     return ProjectSchema().load(response.json()['body'])
Beispiel #14
0
 def project(self, project_id: int) -> Project:
     response = self.client.get(f'/projects/{project_id}')
     return ProjectSchema().load(response.json()['body'], many=False)