Exemplo n.º 1
0
    def test_get_anonymous_user_id_returns_none_for_non_existing_users(self):
        """
        Tests for anonymous_user_id method to return None username does not exist in system.
        """
        django_user_service = DjangoXBlockUserService(self.user, user_is_staff=True)

        anonymous_user_id = django_user_service.get_anonymous_user_id(username="******", course_id='edx/toy/2012_Fall')
        self.assertIsNone(anonymous_user_id)
Exemplo n.º 2
0
    def test_get_anonymous_user_id_returns_none_for_non_staff_users(self):
        """
        Tests for anonymous_user_id method to return None if user is Non-Staff.
        """
        django_user_service = DjangoXBlockUserService(self.user,
                                                      user_is_staff=False)

        anonymous_user_id = django_user_service.get_anonymous_user_id(
            username=self.user.username, course_id='edx/toy/2012_Fall')
        assert anonymous_user_id is None
Exemplo n.º 3
0
    def test_get_anonymous_user_id_returns_id_for_existing_users(self):
        """
        Tests for anonymous_user_id method returns anonymous user id for a user.
        """
        course_key = CourseKey.from_string('edX/toy/2012_Fall')
        anon_user_id = anonymous_id_for_user(user=self.user,
                                             course_id=course_key)

        django_user_service = DjangoXBlockUserService(self.user,
                                                      user_is_staff=True)
        anonymous_user_id = django_user_service.get_anonymous_user_id(
            username=self.user.username, course_id='edX/toy/2012_Fall')

        assert anonymous_user_id == anon_user_id