How to use the richie.apps.courses.models.Course.objects.count function in richie

To help you get started, we’ve selected a few richie examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openfun / richie / tests / apps / courses / test_admin_page_snapshot.py View on Github external
self.add_permission(user, "add_page")
        if not can_add_page and random.choice([True, False]):
            self.add_permission(user, "change_page")

        # Trigger the creation of a snapshot for the course
        url = "/en/admin/courses/course/{:d}/snapshot/".format(course.id)
        with mock.patch("time.time", mock.MagicMock(return_value=1541946888)):
            response = self.client.post(url, follow=True)

        self.assertEqual(response.status_code, 403)
        self.assertEqual(
            response.content,
            b"You don't have sufficient permissions to snapshot this page.",
        )
        # No additional courses should have been created
        self.assertEqual(Course.objects.count(), 2)
github openfun / richie / tests / apps / courses / test_models_person.py View on Github external
def test_models_person_get_courses_several_languages(self):
        """
        The courses should not be duplicated if they exist in several languages.
        """
        person = PersonFactory(should_publish=True)
        CourseFactory(
            page_title={"en": "my title", "fr": "mon titre"},
            fill_team=[person],
            should_publish=True,
        )
        self.assertEqual(Course.objects.count(), 2)
        self.assertEqual(person.get_courses().count(), 1)