-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
212 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import unittest | ||
import requests | ||
|
||
from .base import BaseCase | ||
|
||
|
||
class TestUser(BaseCase): | ||
|
||
def test_user_post(self): | ||
""" | ||
Checks for a 201 response from the /courses endpoint | ||
Checks for the correct response message | ||
""" | ||
user_data = { | ||
"userId": "EVANs", | ||
} | ||
|
||
response = requests.post(self.host() + '/users', json=user_data, headers={'Accept': 'application/json'}) | ||
|
||
self.assertEqual(201, response.status_code) | ||
self.assertEqual("User Added", response.json()) | ||
|
||
|
||
def test_user_post_missing(self): | ||
""" | ||
Checks for a 201 response from the /courses endpoint | ||
Checks for the correct response message | ||
""" | ||
user_data = { | ||
"filler": "meow", | ||
} | ||
|
||
response = requests.post(self.host() + '/users', json=user_data, headers={'Accept': 'application/json'}) | ||
|
||
self.assertEqual(400, response.status_code) | ||
self.assertEqual("Missing userId", response.json()) | ||
|
||
|
||
def test_user_post_double(self): | ||
""" | ||
Checks for a 201 response from the /courses endpoint | ||
Checks for the correct response message | ||
""" | ||
user_data = { | ||
"userId": "DoughBell", | ||
} | ||
|
||
response = requests.post(self.host() + '/users', json=user_data, headers={'Accept': 'application/json'}) | ||
|
||
self.assertEqual(201, response.status_code) | ||
self.assertEqual("User Added", response.json()) | ||
|
||
response = requests.post(self.host() + '/users', json=user_data, headers={'Accept': 'application/json'}) | ||
|
||
self.assertEqual(409, response.status_code) | ||
self.assertEqual("User already exists", response.json()) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |