def test_can_update_field(self): new_title = u"Poopity Poop Pooh" request = self.factory.post(self.url, self.generate(title=new_title)) request.user = self.user view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) obj = Article.objects.get(pk=1) self.assertEqual(obj.title, new_title)
def test_can_delete_field(self): # TODO finish writing me data = self.generate() request = self.factory.delete(self.url, data) request.user = self.user request.DELETE = data # FIXME this is wrong view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) with self.assertRaises(Article.DoesNotExist): Article.objects.get(pk=data['pk'])
def test_can_update_field(self): new_title = u"Poopity Poop Pooh" request = self.factory.post(self.url, self.generate(title=new_title) ) request.user = self.user view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) obj = Article.objects.get(pk=1) self.assertEqual(obj.title, new_title)
def test_can_create_instance(self): # TODO finish writing me new_title = 'Inserted with PUT' data = self.generate(title=new_title) data.pop('pk') request = self.factory.put(self.url, data) request.user = self.user request.PUT = data # FIXME this is wrong view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) Article.objects.get(title=new_title)
def test_can_update_field(self): from django.contrib.contenttypes.models import ContentType from reversion.models import Version new_title = u"Title {0}".format(random.randint(0, 99)) request = self.factory.post(self.url, self.generate(title=new_title)) request.user = self.user view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) obj = Article.objects.get(pk=1) self.assertEqual(obj.title, new_title) article_type = ContentType.objects.get(model='article') versions = Version.objects.filter( content_type=article_type, object_repr=new_title, ) self.assertTrue(versions.get())
def test_can_update_field(self): from django.contrib.contenttypes.models import ContentType from reversion.models import Version new_title = u"Title {0}".format(random.randint(0, 99)) request = self.factory.post(self.url, self.generate(title=new_title) ) request.user = self.user view = ContentEditableView.as_view() response = view(request) self.assertEqual(response.status_code, 200) obj = Article.objects.get(pk=1) self.assertEqual(obj.title, new_title) article_type = ContentType.objects.get(model='article') versions = Version.objects.filter( content_type=article_type, object_repr=new_title, ) self.assertTrue(versions.get())
def test_api_is_off_when_disabled(self): view = ContentEditableView.as_view() request = self.factory.post(self.url, self.generate()) request.user = self.user with self.assertRaises(Http404): view(request)