Advertisement
Guest User

Untitled

a guest
Mar 8th, 2016
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. def setUp(self):
  2. self.api_client = APIClient()
  3.  
  4. def test_api_update(self):
  5. # Create an entry
  6. entry = self.Meta.factory.create()
  7.  
  8. url = reverse(self.api_model_url + '-detail', args=[str(entry.id)])
  9.  
  10. data = {'key': 'Modified Entry', 'comment': 'Modified Comment', 'position': 7}
  11.  
  12. # Check that an entry cannot be altered by an unauthenticated user via the API
  13. response = self.api_client.put(url, data, format='json')
  14. contents = self.parse_json_response(response, Status.HTTP_403_FORBIDDEN)
  15.  
  16. # Check that an entry cannot be altered by a normal authenticated user via the API
  17. self.api_client.login(username='normal-user', password='normal')
  18. response = self.api_client.put(url, data, format='json')
  19. contents = self.parse_json_response(response, Status.HTTP_403_FORBIDDEN)
  20.  
  21. # Check that an entry can be altered by an administrator via the API
  22. self.api_client.login(username='admin-user', password='admin')
  23. response = self.api_client.put(url, data, format='json')
  24. contents = self.parse_json_response(response, Status.HTTP_201_CREATED)
  25.  
  26. class LookupFactory(factory.django.DjangoModelFactory):
  27. comment = factory.LazyAttribute(lambda x: faker.sentence(nb_words=10))
  28. position = factory.Sequence(lambda n: n)
  29. key = factory.Sequence(lambda n: 'Status {0:04d}'.format(n))
  30.  
  31. django.db.utils.IntegrityError: insert or update on table "reversion_version" violates foreign key constraint "reversion_version_content_type_id_fkey"
  32. DETAIL: Key (content_type_id)=(855) is not present in table "django_content_type".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement