Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add integration tests #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
340 changes: 340 additions & 0 deletions tests/autotests.json
Original file line number Diff line number Diff line change
@@ -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",
"});"
]
}
}
]
}
15 changes: 15 additions & 0 deletions tests/local_env.json
Original file line number Diff line number Diff line change
@@ -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"
}
Loading