Commit 1ab78a62 authored by Jean-samuel TETTEKPOE's avatar Jean-samuel TETTEKPOE
Browse files

Solve integrity error

parent aadd3193
......@@ -14,7 +14,6 @@ class BugreportTests(APITestCase):
self.create_data = {'message': 'test', 'data': 'error'}
def test_create_bugreport(self):
# Unauthenticated
response = self.client.post('/bugreport/?bar=natationjone', self.create_data)
......@@ -31,7 +30,7 @@ class BugreportTests(APITestCase):
# Correct permissions
with patch.object(User, 'has_perm', return_value=True) as m:
self.client.force_authenticate(user=self.user)
response = self.client.post('/bugreport/?bar=natationjone', self.create_data)
response = self.client.post('/bugreport/?bar=natationjone', self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
self.assertEqual(m.call_args[0][0], 'bars_bugtracker.add_bugreport')
......
......@@ -288,7 +288,7 @@ class AccountTests(APITestCase):
def test_create_account2(self):
# Correct permissions
self.client.force_authenticate(user=self.user2)
response = self.client.post('/account/?bar=natationjone', self.create_data)
response = self.client.post('/account/?bar=natationjone', self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
def test_create_account3(self):
......@@ -371,7 +371,7 @@ class RoleTests(APITestCase):
def test_create_role2(self):
# Correct permissions
self.client.force_authenticate(user=self.user2)
response = self.client.post('/role/?bar=natationjone', self.create_data)
response = self.client.post('/role/?bar=natationjone', self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
def test_create_role3(self):
......@@ -387,5 +387,5 @@ class RoleTests(APITestCase):
def test_create_role_root2(self):
self.client.force_authenticate(user=self.root)
response = self.client.post('/role/?bar=root', self.create_data_root)
response = self.client.post('/role/?bar=root', self.create_data_root, content_type="application/json")
self.assertEqual(response.status_code, 201)
......@@ -37,7 +37,7 @@ class AutoTestCreateBarMixin():
def test_create2(self):
# Correct permissions
self.client.force_authenticate(user=self.staff_user)
response = self.client.post(self.create_url % self.bar.id, self.create_data)
response = self.client.post(self.create_url % self.bar.id, self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
def test_create3(self):
......@@ -273,13 +273,11 @@ class SuggestedItemTests(APITestCase):
self.update_data = {'name': 'Thon'}
self.suggesteditem, _ = SuggestedItem.objects.get_or_create(bar=self.bar, name='')
def test_get_suggesteditems(self):
response = self.client.get('/suggesteditem/?bar=natationjone')
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0]['name'], self.suggesteditem.name)
def test_create_suggesteditems(self):
# Unauthenticated
response = self.client.post('/suggesteditem/?bar=natationjone', self.create_data)
......@@ -294,7 +292,7 @@ class SuggestedItemTests(APITestCase):
def test_create_suggesteditems2(self):
# Correct permissions
self.client.force_authenticate(user=self.user2)
response = self.client.post('/suggesteditem/?bar=natationjone', self.create_data)
response = self.client.post('/suggesteditem/?bar=natationjone', self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
def test_create_suggesteditems3(self):
......
......@@ -49,7 +49,7 @@ class MenuTests(APITestCase):
def test_create_menu_2(self):
# Correct permissions
self.client.force_authenticate(user=self.user1)
response = self.client.post('/menu/?bar=avironjone', self.create_data, format='json')
response = self.client.post('/menu/?bar=avironjone', self.create_data, format='json', content_type="application/json")
self.assertEqual(response.status_code, 201)
self.assertEqual(len(response.data['items']), 2)
......
......@@ -22,13 +22,11 @@ class NewsTests(APITestCase):
self.create_data = {'name': 'test', 'text': 'example'}
self.news, _ = News.objects.get_or_create(bar=self.bar, author=self.user, name='', text='')
def test_get_news(self):
response = self.client.get('/news/')
self.assertEqual(len(response.data), 1)
self.assertEqual(response.data[0]['name'], self.news.name)
def test_create_news(self):
# Unauthenticated
response = self.client.post('/news/?bar=natationjone', self.create_data)
......@@ -43,7 +41,7 @@ class NewsTests(APITestCase):
def test_create_news2(self):
# Correct permissions
self.client.force_authenticate(user=self.user2)
response = self.client.post('/news/?bar=natationjone', self.create_data)
response = self.client.post('/news/?bar=natationjone', self.create_data, content_type="application/json")
self.assertEqual(response.status_code, 201)
def test_create_news3(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment