Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def setUp(self):
- self.api_client = APIClient()
- def test_api_update(self):
- # Create an entry
- entry = self.Meta.factory.create()
- url = reverse(self.api_model_url + '-detail', args=[str(entry.id)])
- data = {'key': 'Modified Entry', 'comment': 'Modified Comment', 'position': 7}
- # Check that an entry cannot be altered by an unauthenticated user via the API
- response = self.api_client.put(url, data, format='json')
- contents = self.parse_json_response(response, Status.HTTP_403_FORBIDDEN)
- # Check that an entry cannot be altered by a normal authenticated user via the API
- self.api_client.login(username='normal-user', password='normal')
- response = self.api_client.put(url, data, format='json')
- contents = self.parse_json_response(response, Status.HTTP_403_FORBIDDEN)
- # Check that an entry can be altered by an administrator via the API
- self.api_client.login(username='admin-user', password='admin')
- response = self.api_client.put(url, data, format='json')
- contents = self.parse_json_response(response, Status.HTTP_201_CREATED)
- class LookupFactory(factory.django.DjangoModelFactory):
- comment = factory.LazyAttribute(lambda x: faker.sentence(nb_words=10))
- position = factory.Sequence(lambda n: n)
- key = factory.Sequence(lambda n: 'Status {0:04d}'.format(n))
- django.db.utils.IntegrityError: insert or update on table "reversion_version" violates foreign key constraint "reversion_version_content_type_id_fkey"
- DETAIL: Key (content_type_id)=(855) is not present in table "django_content_type".
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement