Skip to content

Instantly share code, notes, and snippets.

@georgedorn
Created July 15, 2011 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgedorn/1085640 to your computer and use it in GitHub Desktop.
Save georgedorn/1085640 to your computer and use it in GitHub Desktop.
index 146ac15..647a826 100644
--- a/tests/core/tests/resources.py
+++ b/tests/core/tests/resources.py
@@ -1404,6 +1404,24 @@ class ModelResourceTestCase(TestCase):
self.assertTrue("resource_uri" in data)
self.assertTrue("title" in data)
self.assertTrue("is_active" in data)
+
+ def test_post_list_duplicate(self):
+ self.assertEqual(Note.objects.count(), 6)
+ resource = NoteResource()
+ request = MockRequest()
+ request.GET = {'format': 'json'}
+ request.method = 'POST'
+ request.raw_post_data = '{"id": 1, "content": "Duplicate Note.", "created": "2010-04-03 20:05:00", "is_active": true, "slug": "dupe-post", "title": "Duplicate Post", "updated": "2010-04-03
+ try:
+ resp = resource.post_list(request)
+ except:
+ pass #it should raise an exception, don't know what type
+
+ #ensure that note with id 1 is unchanged
+ note = Note.objects.get(pk=1)
+ self.assertEqual(note.title, "First Post!")
+ self.assertEqual(note.slug, "first-post")
+
def test_post_detail(self):
resource = NoteResource()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment