def test_student_state(self, expected_state): """ Verify the service gets the correct state from the student module. Scenario: Given a user and a problem or block Then create a student module entry for the user If the state is obtained from student module service Then the state is equal to previously created student module state """ self._create_student_module(expected_state) state = UserStateService().get_state_as_dict(self.user.username, self.problem.location) self.assertDictEqual(state, expected_state)
def test_nonexistent_student_module_state(self, state_params, should_use_email): """ Verify the user state service returns empty dict for non-existent student module entry. Scenario: Given a user and a problem/block Then create a student module entry for the user If the state is obtained with incorrect parameters Then an empty dict is returned """ params = { 'username_or_email': self._get_email_or_username(should_use_email), 'block_id': self.problem.location } params.update(state_params) self._create_student_module({'key_1': 'value_1'}) state = UserStateService().get_state_as_dict(**params) assert not state