User Tours are walkthroughs we are able to give in our frontends. This sets up the backend support for them by creating the model, setting up the initial backfill, adds in a signal handler to init the UserTour model on User creation, and sets up some endpoints to get user tour information and update it. It is also being initialized with a waffle flag to control the rollout. The flag is intended to control all tours and not allow for opting into only some tours.
24 lines
852 B
Python
24 lines
852 B
Python
""" Tests for UserTour Signal Handlers. """
|
|
|
|
from django.test import TestCase
|
|
|
|
from common.djangoapps.student.tests.factories import UserFactory
|
|
from lms.djangoapps.user_tours.models import UserTour
|
|
|
|
|
|
class TestUserTourHandlers(TestCase):
|
|
""" Tests for UserTour Signal Handlers. """
|
|
def test_successful_handle(self):
|
|
"""
|
|
Tests a UserTour is created when a new User is created.
|
|
Then ensures a new UserTour is not created when the user is updated.
|
|
"""
|
|
assert UserTour.objects.count() == 0
|
|
user = UserFactory()
|
|
tour = UserTour.objects.get(user=user)
|
|
assert tour.course_home_tour_status == UserTour.CourseHomeChoices.NEW_USER_TOUR
|
|
assert tour.show_courseware_tour is True
|
|
user.username = 'new-username'
|
|
user.save()
|
|
assert UserTour.objects.count() == 1
|