8000 Made changes to Postman collection to cater for changing IDs. Modifie… · AndGub/testing-python-apps@8279cc0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8279cc0

Browse files
committed
Made changes to Postman collection to cater for changing IDs. Modified .gitignore to ignore data.db.
1 parent 00ba3bf commit 8279cc0

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ videos/
99
venv/
1010
testing-python-apps.txt
1111
theme.key
12+
data.db

section5/stores-rest-api.postman_collection.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,16 @@
100100
"exec": [
101101
"var jsonData = JSON.parse(responseBody);",
102102
"tests[\"Store name is returned\"] = jsonData.name === 'test_store';",
103+
"tests[\"Store id is returned\"] = jsonData.id === 1;",
104+
"tests[\"Store items are an empty list\"] = jsonData.items.length === 0;",
105+
"",
103106
"tests[\"Successful POST request\"] = responseCode.code === 201;",
104107
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
105108
"",
106109
"tests[\"Content-Type is present\"] = postman.getResponseHeader(\"Content-Type\");",
107-
"tests[\"Content-Type is 'application/json'\"] = postman.getResponseHeader(\"Content-Type\") === 'application/json';"
110+
"tests[\"Content-Type is 'application/json'\"] = postman.getResponseHeader(\"Content-Type\") === 'application/json';",
111+
"",
112+
"postman.setEnvironmentVariable(\"store_id\", jsonData.id);"
108113
]
109114
}
110115
}
@@ -150,7 +155,7 @@
150155
],
151156
"body": {
152157
"mode": "raw",
153-
"raw": "{\n\t\"price\": 17.99,\n\t\"store_id\": 1\n}"
158+
"raw": "{\n\t\"price\": 17.99,\n\t\"store_id\": {{store_id}}\n}"
154159
},
155160
"description": ""
156161
},
@@ -166,6 +171,7 @@
166171
"exec": [
167172
"var jsonData = JSON.parse(responseBody);",
168173
"tests[\"Store 'test_store' is returned\"] = jsonData.stores[0].name === 'test_store';",
174+
"tests[\"ID of store 'test_store' is returned\"] = jsonData.stores[0].id === parseInt(environment.store_id);",
169175
"tests[\"Item 'test_item' is returned inside 'test_store'\"] = jsonData.stores[0].items[0].name === 'test_item';",
170176
"tests[\"Item 'test_item' price is returned inside 'test_store'\"] = jsonData.stores[0].items[0].price === 17.99;",
171177
"",

section5/video_code/models/item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, name, price, store_id):
1717
self.store_id = store_id
1818

1919
def json(self):
20-
return {'name': self.name, 'price': self.price}
20+
return {'id': self.id, 'name': self.name, 'price': self.price}
2121

2222
@classmethod
2323
def find_by_name(cls, name):

section5/video_code/models/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def __init__(self, name):
1313
self.name = name
1414

1515
def json(self):
16-
return {'name': self.name, 'items': [item.json() for item in self.items.all()]}
16+
return {'id': self.id, 'name': self.name, 'items': [item.json() for item in self.items.all()]}
1717

1818
@classmethod
1919
def find_by_name(cls, name):

0 commit comments

Comments
 (0)
0