def test_returns_string_for_all_objects(self): # pylint: disable=no-self-use """model-to-string returns correct strings""" e1 = EdxAuthorFactory.create() e2 = EdxAuthorFactory.create() co = CourseFactory.create() co.instructors.add(e1) co.instructors.add(e2) f = SMMF(model=EdxAuthor, lookup="edx_uid") assert sorted([str(e1), str(e2)]) == sorted(f.to_representation(co.instructors))
def test_user_exists(self): """If no uid not set, 400""" course = CourseFactory.create() author = EdxAuthorFactory.create(edx_uid=str(uuid.uuid4().hex)) course.instructors.add(author) resp = self.client.get(reverse('user-existence'), {'uid': author.edx_uid}) self.assertEqual(resp.status_code, 200) self.assertEqual(json.loads(resp.content.decode('utf-8')), {'exists': True})