Skip to content

Commit

Permalink
e2e tests in python
Browse files Browse the repository at this point in the history
  • Loading branch information
araujo88 committed Apr 9, 2024
1 parent 2e6315c commit 9fc0e41
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/e2e.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import unittest
import requests

class TestPersonAPI(unittest.TestCase):
BASE_URL = 'http://localhost:6969'

def test_post_person(self):
url = f"{self.BASE_URL}/v1/person"
payload = {'name': 'John Doe', 'age': 30}
headers = {'Content-Type': 'application/json'}

response = requests.post(url, json=payload, headers=headers)
self.assertEqual(response.status_code, 201)

def test_get_persons(self):
url = f"{self.BASE_URL}/v1/person"

response = requests.get(url)
self.assertEqual(response.status_code, 200)

def test_get_unknown_route(self):
url = f"{self.BASE_URL}/42"

response = requests.get(url)
self.assertEqual(response.status_code, 404)

def test_get_person_by_id(self):
url = f"{self.BASE_URL}/v1/person/0"

response = requests.get(url)
self.assertEqual(response.status_code, 200)

def test_get_person_by_id_not_found(self):
url = f"{self.BASE_URL}/v1/person/42"

response = requests.get(url)
self.assertEqual(response.status_code, 404)


if __name__ == '__main__':
unittest.main()

0 comments on commit 9fc0e41

Please sign in to comment.