Ejemplo n.º 1
0
    def test_save_deletes_cached_enrollment_status_hash(self):
        """ Verify the method deletes the cached enrollment status hash for the user. """
        # There should be no cached value for a new user with no enrollments.
        self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))

        # Generating a status hash should cache the generated value.
        status_hash = CourseEnrollment.generate_enrollment_status_hash(self.user)
        self.assert_enrollment_status_hash_cached(self.user, status_hash)

        # Modifying enrollments should delete the cached value.
        CourseEnrollmentFactory.create(user=self.user)
        self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))
Ejemplo n.º 2
0
    def test_save_deletes_cached_enrollment_status_hash(self):
        """ Verify the method deletes the cached enrollment status hash for the user. """
        # There should be no cached value for a new user with no enrollments.
        self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))

        # Generating a status hash should cache the generated value.
        status_hash = CourseEnrollment.generate_enrollment_status_hash(self.user)
        self.assert_enrollment_status_hash_cached(self.user, status_hash)

        # Modifying enrollments should delete the cached value.
        CourseEnrollmentFactory.create(user=self.user)
        self.assertIsNone(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(self.user)))
Ejemplo n.º 3
0
 def assert_enrollment_status_hash_cached(self, user, expected_value):
     self.assertEqual(
         cache.get(CourseEnrollment.enrollment_status_hash_cache_key(user)),
         expected_value)
Ejemplo n.º 4
0
 def test_enrollment_status_hash_cache_key(self):
     username = '******'
     user = UserFactory(username=username)
     expected = 'enrollment_status_hash_' + username
     self.assertEqual(
         CourseEnrollment.enrollment_status_hash_cache_key(user), expected)
Ejemplo n.º 5
0
 def assert_enrollment_status_hash_cached(self, user, expected_value):
     self.assertEqual(cache.get(CourseEnrollment.enrollment_status_hash_cache_key(user)), expected_value)
Ejemplo n.º 6
0
 def test_enrollment_status_hash_cache_key(self):
     username = '******'
     user = UserFactory(username=username)
     expected = 'enrollment_status_hash_' + username
     self.assertEqual(CourseEnrollment.enrollment_status_hash_cache_key(user), expected)