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)
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)
def projects(self) -> List[Project]: response = self.client.get('/projects', allowed_statuses=(200, )) return ProjectSchema().load(response.json()['body'], many=True)
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
def project_schema(): return ProjectSchema()
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
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
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
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]
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
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
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]
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'])
def project(self, project_id: int) -> Project: response = self.client.get(f'/projects/{project_id}') return ProjectSchema().load(response.json()['body'], many=False)