def _install_masquerade(self, user, role='student'): """ Installs a masquerade for the specified user. """ user.masquerade_settings = { self.course_key: CourseMasquerade(self.course_key, role=role) }
def test_unpickling_sets_all_attributes(self): """ Make sure that old CourseMasquerade objects receive missing attributes when unpickled from the session. """ cmasq = CourseMasquerade(7) del cmasq.user_name pickled_cmasq = pickle.dumps(cmasq) unpickled_cmasq = pickle.loads(pickled_cmasq) self.assertEqual(unpickled_cmasq.user_name, None)