Skip to content

Commit

Permalink
testing POST in comments entrypoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JennyRemolina committed Jul 12, 2019
1 parent cf77c9a commit a2128a6
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion api/tests/test_comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ def setUp(self):
"text": "This task is very important",
}
self.comment = Comment.objects.create(**self.data)
self.data['creator'] = self.jefe.id
self.data['task'] = self.task.id
self.data['jefe'] = self.jefe.id


def test_read_comments_get(self):
"""
Expand All @@ -55,3 +56,21 @@ def test_read_comments_get(self):
commentSerial = CommentSerializer(instance=self.comment)
print(commentSerial.data)
self.assertEqual(commentSerial.data, response_data['results'][0])


def test_create_task_post(self):
"""
Test to verify POST task valid
"""
self.data['text'] = "Keep deadline"
response = self.client.post(self.url, self.data)
print(response.status_code, response.content)
self.assertEqual(201, response.status_code)

url = self.url + '?task={id}'.format(id=self.task.id)
response = self.client.get(url)
print(response.status_code, response.content)
self.assertEqual(200, response.status_code)
response_data = json.loads(response.content)
self.assertEqual(2, response_data['count']) # 2 comments

0 comments on commit a2128a6

Please sign in to comment.