Ejemplo n.º 1
0
    def test_course_bulk_notification_tests(self):
        # create new users and enroll them in the course.
        startup.startup_notification_subsystem()

        test_user_1 = UserFactory.create(password='******')
        CourseEnrollmentFactory(user=test_user_1, course_id=self.course.id)
        test_user_2 = UserFactory.create(password='******')
        CourseEnrollmentFactory(user=test_user_2, course_id=self.course.id)

        notification_type = get_notification_type(u'open-edx.studio.announcements.new-announcement')
        course = modulestore().get_course(self.course.id, depth=0)
        notification_msg = NotificationMessage(
            msg_type=notification_type,
            namespace=unicode(self.course.id),
            payload={
                '_schema_version': '1',
                'course_name': course.display_name,

            }
        )
        # Send the notification_msg to the Celery task
        publish_course_notifications_task.delay(self.course.id, notification_msg)

        # now the enrolled users should get notification about the
        # course update where they are enrolled as student.
        self.assertTrue(get_notifications_count_for_user(test_user_1.id), 1)
        self.assertTrue(get_notifications_count_for_user(test_user_2.id), 1)
Ejemplo n.º 2
0
    def setUp(self):
        """
        These tests need a user in the DB so that the django Test Client can log them in.
        The test user is created in the ModuleStoreTestCase setUp method.
        They inherit from the ModuleStoreTestCase class so that the mongodb collection
        will be cleared out before each test case execution and deleted
        afterwards.
        """

        self.user_password = super(CourseTestCase, self).setUp()

        self.client = AjaxEnabledTestClient()
        self.client.login(username=self.user.username, password=self.user_password)

        self.course = CourseFactory.create()

        # initialize the Notification subsystem
        startup.startup_notification_subsystem()
Ejemplo n.º 3
0
    def setUp(self):
        """
        These tests need a user in the DB so that the django Test Client can log them in.
        The test user is created in the ModuleStoreTestCase setUp method.
        They inherit from the ModuleStoreTestCase class so that the mongodb collection
        will be cleared out before each test case execution and deleted
        afterwards.
        """

        super(CourseTestCase, self).setUp()

        self.client = AjaxEnabledTestClient()
        self.client.login(username=self.user.username,
                          password=self.user_password)

        self.course = CourseFactory.create()

        # initialize the Notification subsystem
        startup.startup_notification_subsystem()