diff --git a/tests/autotests.json b/tests/autotests.json new file mode 100644 index 0000000..37313c3 --- /dev/null +++ b/tests/autotests.json @@ -0,0 +1,340 @@ +{ + "info": { + "_postman_id": "867823eb-4831-40e5-9af1-f3f1ff1da5d1", + "name": "Auto Tests", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", + "_exporter_id": "24756275", + "_collection_link": "https://martian-astronaut-975194.postman.co/workspace/Codebattles~ac8c92c5-94b1-4349-a4b4-70c488f6046d/collection/24756275-867823eb-4831-40e5-9af1-f3f1ff1da5d1?action=share&source=collection_link&creator=24756275" + }, + "item": [ + { + "name": "0. Login", + "item": [ + { + "name": "Login test", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "pm.test(\"Success field test\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eql(true);\r", + "});\r", + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"id\": \"1\",\r\n \"login\": \"17773\",\r\n \"password\": \"01098\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{url}}/api/login", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "login" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "1. Checkers Test", + "item": [ + { + "name": "1.1 Valid program", + "item": [ + { + "name": "1.1.1 Send program to test", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "\r", + "pm.test(\"Success field test\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eql(true);\r", + "});\r", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"src\": \"print(int(input()) + int(input()))\",\r\n \"cars\": \"1\",\r\n \"problem\": \"A\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{url}}/api/send", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "send" + ] + } + }, + "response": [] + }, + { + "name": "1.1.2 Get tested result", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "\r", + "pm.test(\"Success field test\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eql(true);\r", + "});\r", + "\r", + "pm.test(\"Test send check\", function () {\r", + " var jsonData = pm.response.json();\r", + "\r", + " const last_send = jsonData.sends[0]\r", + " console.log(last_send)\r", + "\r", + " pm.expect(last_send.program_checked).to.eql(true);\r", + " pm.expect(last_send.score).to.eql(100);\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Wait for test system end tests\r", + "setTimeout(function(){}, [2000]);" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{url}}/api/sends", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "sends" + ] + } + }, + "response": [] + } + ] + }, + { + "name": "1.2 Invalid program", + "item": [ + { + "name": "1.2.1 Send program to test", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "\r", + "pm.test(\"Success field test\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eql(true);\r", + "});\r", + "" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "POST", + "header": [], + "body": { + "mode": "raw", + "raw": "{\r\n \"src\": \"print(\",\r\n \"cars\": \"1\",\r\n \"problem\": \"A\"\r\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{url}}/api/send", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "send" + ] + } + }, + "response": [] + }, + { + "name": "1.2.2 Get tested result", + "event": [ + { + "listen": "test", + "script": { + "exec": [ + "pm.test(\"Status code is 200\", function () {\r", + " pm.response.to.have.status(200);\r", + "});\r", + "\r", + "\r", + "pm.test(\"Success field test\", function () {\r", + " var jsonData = pm.response.json();\r", + " pm.expect(jsonData.success).to.eql(true);\r", + "});\r", + "\r", + "pm.test(\"Test send check\", function () {\r", + " var jsonData = pm.response.json();\r", + "\r", + " const last_send = jsonData.sends[0]\r", + " console.log(last_send)\r", + "\r", + " pm.expect(last_send.program_checked).to.eql(true);\r", + " pm.expect(last_send.score).to.eql(100);\r", + "});" + ], + "type": "text/javascript", + "packages": {} + } + }, + { + "listen": "prerequest", + "script": { + "exec": [ + "// Wait for test system end tests\r", + "setTimeout(function(){}, [2000]);" + ], + "type": "text/javascript", + "packages": {} + } + } + ], + "request": { + "method": "GET", + "header": [], + "url": { + "raw": "{{url}}/api/sends", + "host": [ + "{{url}}" + ], + "path": [ + "api", + "sends" + ] + } + }, + "response": [] + } + ] + } + ] + } + ], + "event": [ + { + "listen": "prerequest", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "" + ] + } + }, + { + "listen": "test", + "script": { + "type": "text/javascript", + "packages": {}, + "exec": [ + "pm.test(\"Content-Type is present\", function () {\r", + " pm.response.to.have.header(\"Content-Type\");\r", + "});\r", + "\r", + "pm.test(\"Response time is less than 500ms\", function () {\r", + " pm.expect(pm.response.responseTime).to.be.below(500);\r", + "});" + ] + } + } + ] +} \ No newline at end of file diff --git a/tests/local_env.json b/tests/local_env.json new file mode 100644 index 0000000..7cd23a2 --- /dev/null +++ b/tests/local_env.json @@ -0,0 +1,15 @@ +{ + "id": "2d18a973-d1e6-4f8c-b36f-5756b32b9986", + "name": "Local", + "values": [ + { + "key": "url", + "value": "localhost:2500", + "type": "default", + "enabled": true + } + ], + "_postman_variable_scope": "environment", + "_postman_exported_at": "2024-03-27T19:47:23.735Z", + "_postman_exported_using": "Postman/10.24.7" +} \ No newline at end of file