From 6463756ed5face322cceb268f60a95527072eb76 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Thu, 18 Jul 2019 09:31:13 +0000 Subject: [PATCH] Add more test scripts for API Controller. Add data to sql file for testing. #229 --- postman/PoC Resq.postman_environment.json | 4 +- ...I - API Controller.postman_collection.json | 447 +++++++++++++++++- .../{resq_test_20190717.sql => resq_test.sql} | 5 + 3 files changed, 443 insertions(+), 13 deletions(-) rename postman/{resq_test_20190717.sql => resq_test.sql} (95%) diff --git a/postman/PoC Resq.postman_environment.json b/postman/PoC Resq.postman_environment.json index c1c10ff6..8b275b29 100755 --- a/postman/PoC Resq.postman_environment.json +++ b/postman/PoC Resq.postman_environment.json @@ -10,10 +10,10 @@ { "key": "api_key", "value": "5d2eedb4b4714", - "enabled": true + "enabled": false } ], "_postman_variable_scope": "environment", - "_postman_exported_at": "2019-07-17T10:22:33.397Z", + "_postman_exported_at": "2019-07-18T09:27:17.254Z", "_postman_exported_using": "Postman/7.2.2" } \ No newline at end of file diff --git a/postman/Resq Mobile API - API Controller.postman_collection.json b/postman/Resq Mobile API - API Controller.postman_collection.json index a967bc9e..475612ce 100755 --- a/postman/Resq Mobile API - API Controller.postman_collection.json +++ b/postman/Resq Mobile API - API Controller.postman_collection.json @@ -26,9 +26,9 @@ " // get session id value", " let session_id = jsonData.data.session_id;", " ", - " // store the session_id value as an environment variable. The session id is the api_key in calls requiring an api_key", + " // store the session_id value as a global variable. The session id is the api_key in calls requiring an api_key", " ", - " pm.environment.set(\"api_key\", session_id);", + " pm.globals.set(\"api_key\", session_id);", "});" ], "type": "text/javascript" @@ -368,11 +368,376 @@ }, { "name": "[Normal] List Vehicle Makes", + "event": [ + { + "listen": "test", + "script": { + "id": "74a802f4-f8ea-4059-a18a-206d29a50199", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"List Vehicle Makes\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " pm.expect(jsonData.data.manufacturer.name).to.eql(\"VOLKSWAGEN\");", + " pm.expect(jsonData.data.makes).to.have.lengthOf(27);", + " pm.expect(jsonData.data.makes[0].make).to.eql(\"BEETLE 2013 - 2018\");", + "});" + ], + "type": "text/javascript" + } + } + ], "request": { "method": "GET", "header": [], "url": { - "raw": "" + "raw": "{{resq_url}}/api/vehicle/mfgs/{{mfg_id}}/makes?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "vehicle", + "mfgs", + "{{mfg_id}}", + "makes" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] + } + }, + "response": [] + }, + { + "name": "[Normal] Add Vehicle", + "event": [ + { + "listen": "test", + "script": { + "id": "efd6f228-c8d6-4e52-a9d1-fca7b5e3220e", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Add vehicle\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " pm.expect(jsonData.data).to.have.property(\"cv_id\");", + " ", + " // store customer vehicle id for update vehicle", + " let cv_id = jsonData.data.cv_id;", + " pm.globals.set(\"cv_id\", cv_id);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "make_id", + "value": "{{make_id}}", + "type": "text" + }, + { + "key": "name", + "value": "{{name}}", + "type": "text" + }, + { + "key": "plate_num", + "value": "{{plate_num}}", + "type": "text" + }, + { + "key": "model_year", + "value": "{{model_year}}", + "type": "text" + }, + { + "key": "color", + "value": "{{color}}", + "type": "text" + }, + { + "key": "condition", + "value": "{{condition}}", + "type": "text" + }, + { + "key": "fuel_type", + "value": "{{fuel_type}}", + "type": "text" + } + ] + }, + "url": { + "raw": "{{resq_url}}/api/vehicles?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "vehicles" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] + } + }, + "response": [] + }, + { + "name": "[Normal] Update Vehicle", + "event": [ + { + "listen": "test", + "script": { + "id": "8cd334bb-4032-47f3-9dcd-8c893135ac7d", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Update vehicle\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " pm.expect(jsonData.data.cv_id).to.eql(pm.globals.get(\"cv_id\"));", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "formdata", + "formdata": [ + { + "key": "make_id", + "value": "{{make_id}}", + "type": "text" + }, + { + "key": "name", + "value": "{{name}}", + "type": "text" + }, + { + "key": "plate_num", + "value": "{{plate_num}}", + "type": "text" + }, + { + "key": "model_year", + "value": "{{model_year}}", + "type": "text" + }, + { + "key": "color", + "value": "{{color}}", + "type": "text" + }, + { + "key": "condition", + "value": "{{condition}}", + "type": "text" + }, + { + "key": "fuel_type", + "value": "{{fuel_type}}", + "type": "text" + }, + { + "key": "wty_code", + "value": "{{wty_code}}", + "type": "text" + }, + { + "key": "wty_expire", + "value": "{{wty_expire}}", + "type": "text" + }, + { + "key": "is_motolite", + "value": "1", + "type": "text" + }, + { + "key": "is_active", + "value": "1", + "type": "text" + } + ] + }, + "url": { + "raw": "{{resq_url}}/api/vehicles/{{cv_id}}?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "vehicles", + "{{cv_id}}" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] + } + }, + "response": [] + }, + { + "name": "[Normal] List Vehicles", + "event": [ + { + "listen": "test", + "script": { + "id": "82efd001-0a54-4c45-b8b5-d996a197a3a6", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"List vehicles\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " pm.expect(jsonData.data.vehicles.length).to.be.gt(0);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{resq_url}}/api/vehicles?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "vehicles" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] + } + }, + "response": [] + }, + { + "name": "[Normal] List Promos", + "event": [ + { + "listen": "test", + "script": { + "id": "5263af3d-5f82-4bef-9575-c0771e78fe1e", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"List promos\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " //pm.expect(jsonData.data.makes).to.have.lengthOf(9);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{resq_url}}/api/promos?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "promos" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] + } + }, + "response": [] + }, + { + "name": "[Normal] Get Compatible Batteries", + "event": [ + { + "listen": "test", + "script": { + "id": "8d860fb0-7e8b-4ac9-b229-15df1ade3677", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});", + "", + "pm.test(\"Get compatible batteries\", function () {", + " var jsonData = pm.response.json();", + " pm.expect(jsonData.error.status).to.eql(\"success\");", + " ", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{resq_url}}/api/vehicles/{{make_id}}/compatible_batteries?api_key={{api_key}}", + "host": [ + "{{resq_url}}" + ], + "path": [ + "api", + "vehicles", + "{{make_id}}", + "compatible_batteries" + ], + "query": [ + { + "key": "api_key", + "value": "{{api_key}}" + } + ] } }, "response": [] @@ -402,52 +767,112 @@ ], "variable": [ { - "id": "09fcc1bc-23c3-48cb-8586-49a7cf9437d5", + "id": "b92a8775-f072-45d6-ba3c-c5c1e697026b", "key": "resq_url", "value": "resq.local", "type": "string" }, { - "id": "25934577-a793-4004-badf-63212546aa52", + "id": "279d5bec-f9d3-431c-8ef7-8bce23f18f0f", "key": "phone_model", "value": "iPhone8", "type": "string" }, { - "id": "4e0d2bcf-84bd-4516-b0ef-d28413b62acb", + "id": "a747bcd5-9367-4394-97b1-c3caca435f8d", "key": "os_type", "value": "IOS", "type": "string" }, { - "id": "41b11f18-f02c-4721-bee0-7b7e5d277c42", + "id": "b3833b45-b18b-4aaf-8aa5-064caf7a3e6e", "key": "os_version", "value": "11.4", "type": "string" }, { - "id": "d2fb7606-9d27-4a1c-9701-93d807e02796", + "id": "a515f94f-c3f9-4bbf-9f17-277fa06ab1b3", "key": "phone_id", "value": "11376660-F8BF-46ED-B30A-EF3F361EE223", "type": "string" }, { - "id": "2cd58196-a907-4c21-9753-75a6090f4f1b", + "id": "fe0a71cc-64eb-4f69-817b-0a98782749b6", "key": "phone_number", "value": "9221111111", "type": "string" }, { - "id": "211fab6f-e9f0-4436-a3a0-351b3bf11eb2", + "id": "c26c982a-7879-4324-9095-229913ee1370", "key": "first_name", "value": "Stiltzkin", "type": "string" }, { - "id": "2943ce9b-545f-489a-bee6-d3553312fd4c", + "id": "c3e57918-f00a-4e6d-9182-f4a86e2f2598", "key": "last_name", "value": "Moogle", "type": "string" + }, + { + "id": "56657131-867e-430d-a7cf-ec2bbb4ce14a", + "key": "mfg_id", + "value": "1435", + "type": "string" + }, + { + "id": "7c6a8217-98e5-4ea1-a3ad-608345e9895c", + "key": "make_id", + "value": "22043", + "type": "string" + }, + { + "id": "971f7ee1-d1b3-43da-afce-f32a1344b59f", + "key": "name", + "value": "Beetle 1.2 TSI MT (Gas)", + "type": "string" + }, + { + "id": "9f1d9e61-1142-45a3-837a-d0c67d6d7731", + "key": "plate_num", + "value": "MGL1234", + "type": "string" + }, + { + "id": "9d01f14b-8a98-41a2-9c50-bb74988219c5", + "key": "model_year", + "value": "2016", + "type": "string" + }, + { + "id": "f0d9c73d-a485-47da-9f55-5ab8e6ec67b8", + "key": "color", + "value": "White", + "type": "string" + }, + { + "id": "2734e723-5e3e-493b-b2ac-baf324ee6c56", + "key": "condition", + "value": "Brand New", + "type": "string" + }, + { + "id": "43d61623-17d2-4502-b225-74b40af420c0", + "key": "fuel_type", + "value": "Gas", + "type": "string" + }, + { + "id": "85fb5ff9-e4b8-4400-9093-54f4258a6780", + "key": "wty_code", + "value": "MKUP0123456", + "type": "string" + }, + { + "id": "34611113-838e-4e43-9964-d69cb3d900aa", + "key": "wty_expire", + "value": "20201125", + "type": "string" } ] } \ No newline at end of file diff --git a/postman/resq_test_20190717.sql b/postman/resq_test.sql similarity index 95% rename from postman/resq_test_20190717.sql rename to postman/resq_test.sql index 19dbfb8f..7060fdfa 100644 --- a/postman/resq_test_20190717.sql +++ b/postman/resq_test.sql @@ -134,6 +134,7 @@ CREATE TABLE `battery` ( LOCK TABLES `battery` WRITE; /*!40000 ALTER TABLE `battery` DISABLE KEYS */; +INSERT INTO `battery` VALUES (1033,1,438,1171,'NS40',21,6,0,0,0,0,0,4950.00,'','WMGB20DB-CPN00-LX',12),(1034,1,438,1172,'NS40R',21,6,0,0,0,0,0,4950.00,'','WMGB20DB-CPN00-LX',12),(1035,1,438,1173,'',21,6,0,0,0,0,0,4950.00,NULL,'WMGB20DB-CPN00-LX',12),(1036,1,438,1174,'NS60',21,6,0,0,0,0,0,5650.00,'','WMGB24DB-CPN00-LX',12),(1037,1,438,1175,'NS60',21,6,0,0,0,0,0,5650.00,'','WMGB24DB-CPN00-LX',12),(1038,1,438,1176,'1SM ',21,6,0,0,0,0,0,5800.00,'','WMGL23DL-CPN00-LX',12),(1039,1,438,1177,'1SM',21,6,0,0,0,0,0,5800.00,'','WMGL23DL-CPN00-LX',12),(1040,1,438,1178,'2SM',21,6,0,0,0,0,0,6300.00,'','WMGL26DL-CPN00-LX',12),(1041,1,438,1179,'2SMR',21,6,0,0,0,0,0,6300.00,'','WMGL26DL-CPN00-LX',12),(1042,1,438,1180,'3SM',21,6,0,0,0,0,0,7500.00,'','WMGL31DL-CPN00-LX',12),(1043,1,438,1181,'3SM ',21,6,0,0,0,0,0,7500.00,'','WMGL31DL-CPN00-LX',12),(1044,1,438,1182,'D20',21,6,0,0,0,0,0,5750.00,'','WMGD204L-TSP00-L',12),(1045,1,438,1183,'DIN44',21,6,0,0,0,0,0,6250.00,'','WMGN44DL-CPN00-L ',12),(1046,1,438,1184,'DIN55',21,6,0,0,0,0,0,7350.00,'','WMGN55DL-CPN00-L',12),(1047,1,438,1185,' ',21,6,0,0,0,0,0,7350.00,'','WMGN55DL-CPN00-L',12),(1048,1,438,1186,'DIN66',21,6,0,0,0,0,0,9150.00,'','WMGN66DL-CPN00-L',12),(1049,1,438,1187,'DIN66R',21,6,0,0,0,0,0,9150.00,'','WMGN66DL-CPN00-L',12),(1050,1,438,1188,'DIN77 H',21,6,0,0,0,0,0,9350.00,'','WMGG94DL-TSP00-L',12),(1051,1,438,1189,'DIN88',21,6,0,0,0,0,0,9800.00,'','WMGN88DL-CPN00-L',12),(1052,1,438,1190,'DIN100',21,6,0,0,0,0,0,12250.00,'','',12),(1053,1,438,1191,'DIN110',21,6,0,0,0,0,0,12250.00,'','WMGG94DL-TSP00-L',12),(1054,1,438,1192,'G34',21,6,0,0,0,0,0,9850.00,'','WMGD78DD-CPP00-L',12),(1055,1,438,1193,'G65',21,6,0,0,0,0,0,10000.00,'','WMGG65DE-CPP00-L',12),(1056,1,439,1175,'',24,8,0,0,0,0,0,6100.00,NULL,'WMXB24EB-CPN00-LX',0),(1057,1,439,1174,'NS60',24,8,0,0,0,0,0,6100.00,'','WMXB24EB-CPN00-LX',0),(1058,1,439,1194,'1SM',24,8,0,0,0,0,0,6350.00,'','WMXL23EL-CPN00-LX',0),(1059,1,439,1195,'2SM EXCEL',24,8,0,0,0,0,0,6700.00,'','WMXX26EL-CPN00-LX',0),(1060,1,439,1180,'X',24,8,0,0,0,0,0,8200.00,'','WMXX31EL-CPN00-LX',0),(1061,1,440,1183,'',15,6,0,0,0,0,0,5000.00,NULL,'WMEN44CL-CPN00-LX',0),(1062,1,440,1197,'',15,6,0,0,0,0,0,4000.00,NULL,'WMEB20CB-CPN00-LX',0),(1063,1,440,1174,' ',15,6,0,0,0,0,0,4550.00,'','WMEB24CB-CPN00-LX',0),(1064,1,440,1175,'',15,6,0,0,0,0,0,4550.00,NULL,'WMEB24CB-CPN00-LX',0),(1065,1,440,1194,' ',15,6,0,0,0,0,0,5050.00,'','WMEL23CL-CPN00-LX',0),(1066,1,440,1195,'',15,6,0,0,0,0,0,5100.00,NULL,'WMEL26CL-CPN00-LX',0),(1067,1,440,1196,'',15,6,0,0,0,0,0,6200.00,NULL,'WMEL31CL-CPN00-LX',0),(1068,1,438,1174,'01mogol',1,1,110,10,10,10,10,1100.00,'','test',12); /*!40000 ALTER TABLE `battery` ENABLE KEYS */; UNLOCK TABLES; @@ -157,6 +158,7 @@ CREATE TABLE `battery_manufacturer` ( LOCK TABLES `battery_manufacturer` WRITE; /*!40000 ALTER TABLE `battery_manufacturer` DISABLE KEYS */; +INSERT INTO `battery_manufacturer` VALUES (1,'Motolite'); /*!40000 ALTER TABLE `battery_manufacturer` ENABLE KEYS */; UNLOCK TABLES; @@ -180,6 +182,7 @@ CREATE TABLE `battery_model` ( LOCK TABLES `battery_model` WRITE; /*!40000 ALTER TABLE `battery_model` DISABLE KEYS */; +INSERT INTO `battery_model` VALUES (438,'GOLD'),(439,'EXCEL'),(440,'ENDURO'); /*!40000 ALTER TABLE `battery_model` ENABLE KEYS */; UNLOCK TABLES; @@ -206,6 +209,7 @@ CREATE TABLE `battery_size` ( LOCK TABLES `battery_size` WRITE; /*!40000 ALTER TABLE `battery_size` DISABLE KEYS */; +INSERT INTO `battery_size` VALUES (1171,'B20 / NS40',288.00,320.00,272.00),(1172,'B20 / NS40 / R',288.00,320.00,272.00),(1173,'B20 / NS40 / R B21 (Ledge)',288.00,320.00,272.00),(1174,'B24 / NS60 ',346.00,384.00,327.00),(1175,'B24 / NS60 / R',346.00,384.00,327.00),(1176,'1SM / D23 /NS50 ',374.00,416.00,354.00),(1177,'1SM / D23 /NS50 / R',374.00,416.00,354.00),(1178,'2SM / D26 /N50 ',449.00,499.00,425.00),(1179,'2SM / D26 /N50 / R',449.00,499.00,425.00),(1180,'3SM / D31 / N70 ',547.00,608.00,517.00),(1181,'3SM / D31 / N70 / R',547.00,608.00,517.00),(1182,'D20',449.00,499.00,425.00),(1183,'DIN44',346.00,384.00,327.00),(1184,'DIN55 ',374.00,416.00,354.00),(1185,'DIN55 / R',374.00,416.00,354.00),(1186,'DIN66 ',432.00,480.00,408.00),(1187,'DIN66 / R',432.00,480.00,408.00),(1188,'DIN77',432.00,480.00,408.00),(1189,'DIN88',576.00,640.00,544.00),(1190,'DIN100',576.00,640.00,544.00),(1191,'DIN110',576.00,640.00,544.00),(1192,'G34',518.00,576.00,490.00),(1193,'G65',490.00,544.00,463.00),(1194,'1SM / D23 / NS50',374.00,416.00,354.00),(1195,'2SM / D26 / N50',449.00,499.00,425.00),(1196,'3SM / N70 / D31',547.00,608.00,517.00),(1197,'NS40 / B20',288.00,320.00,272.00); /*!40000 ALTER TABLE `battery_size` ENABLE KEYS */; UNLOCK TABLES; @@ -834,6 +838,7 @@ CREATE TABLE `promo` ( LOCK TABLES `promo` WRITE; /*!40000 ALTER TABLE `promo` DISABLE KEYS */; +INSERT INTO `promo` VALUES (1,'Employee Discount','EMPLOY',0.4000000000,'opl'),(2,'Grab Discount','GRAB',0.2000000000,'srp'),(3,'Non-Battery Group','NBGROUP',0.0500000000,'srp'),(4,'Petron Fleet Card','PFLEET',0.1000000000,'srp'),(5,'Petron Value Card','PVALUE',0.1000000000,'srp'),(6,'Privilege Discount','PRIV',0.0500000000,'srp'),(7,'Shell Employee Card Holder','SHEMP',0.1000000000,'srp'),(8,'Shell Fleet Card Holder','SHFLEET',0.1000000000,'srp'),(9,'Special Discount','SPDISC',0.1000000000,'srp'); /*!40000 ALTER TABLE `promo` ENABLE KEYS */; UNLOCK TABLES;