Files
edx-platform/lms/djangoapps/user_tours/tests/test_handlers.py
Dillon Dumesnil 2f2a6317a5 feat: AA-1055: Add in User Tours to the platform
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.
2021-11-30 18:21:09 +00:00

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