-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into mark
- Loading branch information
Showing
9 changed files
with
150 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import requests | ||
import test_helper | ||
|
||
|
||
BASE_URL = "http://localhost:3000/api/v2/ItemTypes" | ||
|
||
VALID_ITEM_TYPE = { | ||
"Name": "Test Name", | ||
"Description": "Test Description" | ||
} | ||
|
||
INVALID_ITEM_TYPE_1 = {} | ||
HEADERS = {"Content-Type": "application/json", 'APIKEY': "4125a7b2-7ef8-4c4f-9ff9-3386c0dbcb5c"} | ||
|
||
UPDATED_ITEM_TYPE = { | ||
"id": 1, | ||
"Name": "Updated test name", | ||
"Description": "Updated test description" | ||
} | ||
|
||
|
||
def test_Post(): | ||
# post the test body | ||
post_response = requests.post( | ||
BASE_URL, headers=HEADERS, json=VALID_ITEM_TYPE) | ||
# convert the json response to a string and look for the id of the created Entity | ||
json = str(post_response.json()) | ||
# look here for an integer (digit) | ||
|
||
generated_id = test_helper.get_integer_from_json_string(json) | ||
assert generated_id != 0 | ||
|
||
# get the same entity that has been posted | ||
get_response = requests.get(BASE_URL + f"/{generated_id}", headers=HEADERS) | ||
json = get_response.json() | ||
assert get_response.status_code == 200 | ||
assert json["name"] == VALID_ITEM_TYPE["Name"] | ||
assert json["description"] == VALID_ITEM_TYPE["Description"] | ||
assert "created_at" in json, "created_at key was not created" | ||
assert "updated_at" in json, "updated_at key was not created" | ||
|
||
delete_response = requests.delete( | ||
BASE_URL+f"/{generated_id}", headers=HEADERS) | ||
|
||
assert delete_response.status_code == 200 | ||
|
||
|
||
def test_invalid_post(): | ||
# post an item TYPE with an empty body | ||
post_response = requests.post( | ||
BASE_URL, headers=HEADERS, json=INVALID_ITEM_TYPE_1) | ||
# the response should return a bad request | ||
assert post_response.status_code == 400 | ||
|
||
|
||
def test_put(): | ||
# post an item type | ||
post_response = requests.post( | ||
BASE_URL, headers=HEADERS, json=VALID_ITEM_TYPE) | ||
# convert the json response to a string and look for the id of the created Entity | ||
json = str(post_response.json()) | ||
# look here for an integer (digit) | ||
generated_id = test_helper.get_integer_from_json_string(json) | ||
assert generated_id != 0 | ||
# modify the added item TYPE | ||
UPDATED_ITEM_TYPE["id"] = generated_id | ||
put_response = requests.put( | ||
BASE_URL + f"/{generated_id}", headers=HEADERS, json=UPDATED_ITEM_TYPE) | ||
assert put_response.status_code == 200 | ||
requests.delete(BASE_URL + f"/{generated_id}") | ||
|
||
|
||
def test_put_Item_type_that_does_not_exist(): | ||
put_response = requests.put( | ||
BASE_URL + "999999999999", json=VALID_ITEM_TYPE) | ||
assert put_response.status_code == 404 | ||
|
||
|
||
def test_delete(): | ||
post_response = requests.post(BASE_URL, json=VALID_ITEM_TYPE, headers=HEADERS) | ||
json = str(post_response.json()) | ||
generated_id = test_helper.get_integer_from_json_string(json) | ||
assert generated_id != 0 | ||
|
||
delete_response = requests.delete( | ||
BASE_URL+f"/{generated_id}", headers=HEADERS) | ||
|
||
assert delete_response.status_code == 200 | ||
|
||
get_response = requests.get(BASE_URL + str(generated_id), headers=HEADERS) | ||
assert get_response.status_code == 404 |
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,45 @@ | ||
import requests | ||
import test_helper | ||
|
||
|
||
BASE_URL = "http://localhost:3000/api/v2/items" | ||
|
||
VALID_ITEM = { | ||
"Name": "Test Name", | ||
"Description": "Test Description" | ||
} | ||
|
||
INVALID_ITEM_1 = {} | ||
HEADERS = {"Content-Type": "application/json", 'APIKEY': "4125a7b2-7ef8-4c4f-9ff9-3386c0dbcb5c"} | ||
|
||
UPDATED_ITEM = { | ||
"code": "XLE77785i", | ||
"description": "Focused human-resource implementation", | ||
"short_description": "offer", | ||
"upc_code": "7946503676171", | ||
"model_number": "fM-605648-lbu", | ||
"commodity_code": "qB-2533", | ||
"item_line": 1, | ||
"item_group": 1, | ||
"item_type": 1, | ||
"unit_purchase_quantity": 27, | ||
"unit_order_quantity": 20, | ||
"pack_order_quantity": 16, | ||
"supplier_id": 45, | ||
"supplier_code": "SUP127", | ||
"supplier_part_number": "Ay-062669-VVl" | ||
} | ||
|
||
|
||
def test_invalid_post(): | ||
# post an item TYPE with an empty body | ||
post_response = requests.post( | ||
BASE_URL, headers=HEADERS, json=INVALID_ITEM_1) | ||
# the response should return a bad request | ||
assert post_response.status_code == 400 | ||
|
||
|
||
def test_put_Item_that_does_not_exist(): | ||
put_response = requests.put( | ||
BASE_URL + "999999999999", json=VALID_ITEM) | ||
assert put_response.status_code == 404 |
File renamed without changes.
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
File renamed without changes.
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