示例#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)
示例#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)
示例#3
0
 def projects(self) -> List[Project]:
     response = self.client.get('/projects', allowed_statuses=(200, ))
     return ProjectSchema().load(response.json()['body'], many=True)
示例#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
示例#5
0
def project_schema():
    return ProjectSchema()
示例#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
示例#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
示例#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
示例#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]
示例#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
示例#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
示例#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]
示例#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'])
示例#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)