Commit 373a94a2 authored by Siebers, Michael's avatar Siebers, Michael
Browse files

test endpoint irrelevant/file

parent 691422a0
......@@ -426,6 +426,11 @@ system_test:endpoint_bg@show:
variables:
TEST_NAME: endpoint_bg@show
system_test:endpoint_irrelevant@file:
extends: .system_test:run_with_data_and_db
variables:
TEST_NAME: endpoint_irrelevant@file
system_test:robust against wrong method:
extends: .system_test:run_with_data
variables:
......
......@@ -295,6 +295,7 @@ Queries whether a _single file_ is irrelevant.
| --- | --- | --- | --- |
| Ok | `200` | Success | JSON object with property `result` (=boolean=) |
The response body follows this [JSON schema](</doc/schema/response-irrelevant-file-schema.json>).
#### Example Call
......
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "response-irrelevant-file-schema.json",
"type": "object",
"title": "Irrelevance Response",
"description": "The response body when querying the irrelevance of a file",
"properties": {
"result": {
"type": "boolean"
}
},
"required": [
"result"
]
}
[
{"path": "dir_1/file_old", "expected_result": true},
{"path": "dir_1/file_new", "expected_result": false},
{"path": "dir_2/file_old", "expected_result": true},
{"path": "dir_2/file_new", "expected_result": false},
{"path": "dir_1/dir_a/file_old", "expected_result": true},
{"path": "dir_1/dir_a/file_new", "expected_result": false},
{"path": "dir_1/dir_b/file_old", "expected_result": true},
{"path": "dir_1/dir_b/file_middle", "expected_result": true},
{"path": "dir_1/dir_b/file_new", "expected_result": false},
{"path": "dir_2/dir_a/dir_i/file_old", "expected_result": true},
{"path": "dir_2/dir_a/dir_i/file_middle", "expected_result": true},
{"path": "dir_2/dir_a/dir_i/file_new", "expected_result": false}
]
{
"info": {
"_postman_id": "0b3142c8-cbc8-42b2-a048-77d77978b99b",
"name": "Endpoint irrelevant/file",
"description": "This collection tests the direct responses of the API Endpoint irrelevant/file of the [Reasoning WebAPI for Dare2Del](https://gitlab.rz.uni-bamberg.de/cogsys/dare2del/demonstrator) (Version 1.0.0).\n\nThe collection assumes that the server is started with background knowledge from `endpoint_irrelevant@file-theory_bg.db`.\n\nThe collection is to be run with the data file `endpoint_irrelevant@file-data.json`. The expected results assume that the server has a simple irrelevance rule: \"If two files are in the same folder then the older one (modification time) is irrelevant.\"",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "Querry Irrelevance",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(pm.variables.get(\"test_prefix\") + \"Case: Ok\", function () {",
" pm.expect(pm.response.code).to.eql(200);",
"});",
"",
"var jsonData;",
"",
"pm.test(pm.variables.get(\"test_prefix\") + \"Valid response body\", function() {",
" pm.response.to.be.withBody;",
" pm.response.to.be.json;",
"",
" var Ajv = require('ajv');",
" ajv = new Ajv();",
" const validate = ajv.compile(JSON.parse(pm.variables.get(\"expected-schema\")));",
"",
" jsonData = pm.response.json();",
" pm.expect(validate(jsonData)).to.be.true;",
"});",
"",
"pm.test(pm.variables.get(\"test_prefix\") + \"Correct response\", function() {",
" pm.expect(jsonData.result).to.eql(pm.iterationData.get(\"expected_result\"));",
"});"
],
"type": "text/javascript"
}
},
{
"listen": "prerequest",
"script": {
"exec": [
"if(! pm.collectionVariables.get(\"expected-schema\")) {",
" var code_ok = false;",
" const schema_url = \"http://\" + pm.environment.get(\"SERVER\") + pm.environment.get(\"SCHEMA_PATH\") ",
" + \"/response-irrelevant-file-schema.json\";",
" pm.sendRequest(schema_url, function(err, response){",
" pm.test(\"Load error response schema: Status code is 200\", function () {",
" pm.expect(err).to.not.be.ok;",
" console.log(response);",
" pm.expect(response.code).to.eql(200);",
" code_ok = true;",
" });",
"",
"",
" pm.test(\"Load error response schema: Response is JSON object\", function() {",
" const jsonData = response.json();",
" pm.expect(jsonData).is.an(\"object\");",
"",
" if(code_ok)",
" pm.collectionVariables.set(\"expected-schema\", JSON.stringify(jsonData));",
" });",
" });",
"}",
"",
"pm.variables.set(\"test_prefix\", pm.info.requestName + \" [\" + (pm.info.iteration + 1).toString() + '/' ",
" + pm.info.iterationCount.toString() + ']: ');"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disabledSystemHeaders": {
"connection": true
}
},
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "raw",
"raw": "{\"abs_path\": \"{{path}}\"}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "http://{{SERVER}}/irrelevant/file",
"protocol": "http",
"host": [
"{{SERVER}}"
],
"path": [
"irrelevant",
"file"
]
}
},
"response": []
}
],
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "path",
"value": ""
},
{
"key": "expected_result",
"value": ""
},
{
"key": "expected-schema",
"value": ""
}
]
}
\ No newline at end of file
created(1623231475.084739).
assert(item_(dir_1,directory{abs_path:dir_1,creation_time:1604235209})).
assert(item_('dir_1/file_old',file{abs_path:'dir_1/file_old',access_time:1604711922,change_time:1604711922,creation_time:1604571092,file_size:17369,filename_extension:'',media_type:text,modification_time:1604710192})).
assert(item_('dir_1/file_new',file{abs_path:'dir_1/file_new',access_time:1604719380,change_time:1604711938,creation_time:1604252069,file_size:2342754,filename_extension:csv,media_type:other,modification_time:1604710193})).
assert(item_(dir_2,directory{abs_path:dir_2,creation_time:624782347})).
assert(item_('dir_2/file_old',file{abs_path:'dir_2/file_old',access_time:628345783,change_time:624834578,creation_time:624823457,file_size:17369,filename_extension:'',media_type:text,modification_time:624834578})).
assert(item_('dir_2/file_new',file{abs_path:'dir_2/file_new',access_time:724847806,change_time:724847806,creation_time:624783475,file_size:2342754,filename_extension:csv,media_type:other,modification_time:724834780})).
assert(item_('dir_1/dir_a',directory{abs_path:'dir_1/dir_a',creation_time:1604235709})).
assert(item_('dir_1/dir_a/file_new',file{abs_path:'dir_1/dir_a/file_new',access_time:1605870913,change_time:1605870913,creation_time:1604357091,file_size:12038,filename_extension:txt,media_type:text,modification_time:1604587091})).
assert(item_('dir_1/dir_a/file_old',file{abs_path:'dir_1/dir_a/file_old',access_time:1604379922,change_time:1604379192,creation_time:1604370912,file_size:12479123,filename_extension:pdf,media_type:pdf,modification_time:1604379192})).
assert(item_('dir_1/dir_b',directory{abs_path:'dir_1/dir_b',creation_time:1604257037})).
assert(item_('dir_1/dir_b/file_old',file{abs_path:'dir_1/dir_b/file_old',access_time:1614372311,change_time:1614357237,creation_time:1614257037,file_size:2334634,filename_extension:jpg,media_type:image,modification_time:1614357237})).
assert(item_('dir_1/dir_b/file_middle',file{abs_path:'dir_1/dir_b/file_middle',access_time:1614729192,change_time:1614727992,creation_time:1604270317,file_size:7823156,filename_extension:png,media_type:image,modification_time:1614372799})).
assert(item_('dir_1/dir_b/file_new',file{abs_path:'dir_1/dir_b/file_new',access_time:1614378004,change_time:1614378004,creation_time:1604570361,file_size:897234,filename_extension:jpg,media_type:image,modification_time:1614372800})).
assert(item_('dir_2/dir_a/dir_i',directory{abs_path:'dir_2/dir_a/dir_i',creation_time:734623467})).
assert(item_('dir_2/dir_a/dir_i/file_old',file{abs_path:'dir_2/dir_a/dir_i/file_old',access_time:934467403,change_time:734646740,creation_time:734634670,file_size:72346,filename_extension:csv,media_type:other,modification_time:734646740})).
assert(item_('dir_2/dir_a/dir_i/file_middle',file{abs_path:'dir_2/dir_a/dir_i/file_middle',access_time:746474048,change_time:746474048,creation_time:746234617,file_size:234842,filename_extension:pdf,media_type:pdf,modification_time:746474048})).
assert(item_('dir_2/dir_a/dir_i/file_new',file{abs_path:'dir_2/dir_a/dir_i/file_new',access_time:746475489,change_time:746475489,creation_time:734623472,file_size:145678,filename_extension:jpg,media_type:image,modification_time:746474489})).
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment