Skip to content

Commit

Permalink
Added unittest for GET request
Browse files Browse the repository at this point in the history
  • Loading branch information
Rits1272 committed Dec 9, 2020
1 parent 38eb2d3 commit e2c55f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
Binary file modified DB.db
Binary file not shown.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def get_confession():
'name': confession.name,
'title': confession.message
}, messages))
return jsonify(messages_tuple)
return jsonify(messages_tuple), 200


@app.route('/api/post', methods=['POST'])
Expand Down
11 changes: 11 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from app import app

POST_URL = 'http://127.0.0.1:5000/api/post'
GET_URL = 'http://127.0.0.1:5000/api/get'


class PostConfessionTest(unittest.TestCase):
Expand All @@ -19,3 +20,13 @@ def test_successfull_confession(self):
response = self.app.post(POST_URL, data=payload,
content_type='application/json')
self.assertEqual(201, response.status_code)


class GetConfessionTest(unittest.TestCase):

def setUp(self):
self.app = app.test_client()

def test_successfull_confession(self):
response = self.app.get(GET_URL, content_type='application/json')
self.assertEqual(200, response.status_code)

0 comments on commit e2c55f3

Please sign in to comment.