def get_project_details(self, project_id): """ :param int project_id: Project ID :rtype: ProjectDetails """ response = self.send_request(GET, (PROJECTS_API, project_id), no_trailing_slash=True) return ProjectDetails(**response)
def test_project_id(self, project_id, content_id, course_id): project_details = ProjectDetails(id=project_id, content_id=content_id, course_id=course_id) self.project_api_mock.get_project_by_content_id.return_value = project_details self.assertEqual(self.block.project_details, project_details) self.project_api_mock.get_project_by_content_id.assert_called_once_with( self.block.course_id, self.block.content_id )
def get_project_by_content_id(self, course_id, content_id): """ :param str course_id: Course ID :param str content_id: Content ID :rtype: ProjectDetails """ query_params = {'content_id': content_id, 'course_id': course_id} response = self.send_request(GET, (PROJECTS_API, ), query_params=query_params) assert len(response['results']) <= 1 if not response['results']: return None project = response['results'][0] return ProjectDetails(**project)