Files
edx-platform/lms/djangoapps/courseware/tests/test_user_state_client.py
Ned Batchelder d9dd10dc97 style: code cleanups from Steven Burch (#29292)
* chore: update deprecated import from collections

* chore: remove outdated imports from markdown library

as it hasn't been supported since 2.0.3 and we're on 3.x.
This was deprecated at least as early as 2012!

* docs: add docstring and remove lint-amnesty to markdown plugin

* chore: remove deprecated etree import

* style: remove unnecessary-comprehension for sets

* style: resolve a number of amnestied pylint complaints

Co-authored-by: stvn <stvn@mit.edu>
2021-11-10 07:11:57 -08:00

39 lines
1.2 KiB
Python

"""
Black-box tests of the DjangoUserStateClient against the semantics
defined in edx_user_state_client.
"""
from collections import defaultdict
from django.db import connections
from edx_user_state_client.tests import UserStateClientTestBase
from common.djangoapps.student.tests.factories import UserFactory
from lms.djangoapps.courseware.user_state_client import DjangoXBlockUserStateClient
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
class TestDjangoUserStateClient(UserStateClientTestBase, ModuleStoreTestCase):
"""
Tests of the DjangoUserStateClient backend.
It reuses all tests from :class:`~UserStateClientTestBase`.
"""
__test__ = True
# Tell Django to clean out all databases, not just default
databases = set(connections)
def _user(self, user_idx): # lint-amnesty, pylint: disable=arguments-differ
return self.users[user_idx].username
def _block_type(self, block):
# We only record block state history in DjangoUserStateClient
# when the block type is 'problem'
return 'problem'
def setUp(self):
super().setUp()
self.client = DjangoXBlockUserStateClient()
self.users = defaultdict(UserFactory.create)