コード例 #1
0
 def test_list_courses(self, client, org_name, expected_count):
     org = Organization.objects.get(name=org_name)
     private_courses = CourseOverviewFactory.create_batch(2)
     GroupCourseFactory.create_batch(2, course=private_courses[0], group__organization=org)
     public_courses = [p.course for p in PublicCourseFactory.create_batch(3)]
     OrganizationCourseFactory.create_for(
         org,
         courses=private_courses + public_courses,
     )
     response = client.get(self.url)
     results = response.json()['results']
     assert response.status_code == HTTP_200_OK, response.content
     assert len(results) == expected_count
コード例 #2
0
 def test_list_flags(self, client, org_name, status_code, expected_count):
     """
     List flags correctly with permissions checks.
     """
     org = Organization.objects.get(name=org_name)
     courses = [flag.course for flag in PublicCourseFactory.create_batch(3)]
     _course_org_links = [  # noqa: F841
         OrganizationCourse.objects.create(course_id=str(course.id), organization=org)
         for course in courses
     ]
     response = client.get(self.url)
     assert response.status_code == HTTP_200_OK, response.content
     results = response.json()['results']
     assert len(results) == expected_count