Commit c0b8b938 authored by Rafael Dias's avatar Rafael Dias

Issue #88: Refactor struct of tests

Signed-off-by: Rafael Dias's avatarRafael <rpd17@inf.ufpr.br>
parent ba277989
Pipeline #17827 passed with stages
in 48 seconds
-
name: "dim:2"
dataType: "integer"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:3"
dataType: "string"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:4"
dataType: "string"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:5"
dataType: "boolean"
description: "A dimension of Blendb. Has 2 possible values."
-
name: "dim:6"
dataType: "integer"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:7"
dataType: "integer"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:8"
dataType: "integer"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:9"
dataType: "integer"
parent: "dim:0"
relation: "day"
description: "A dimension of Blendb. Has 30 possible values."
-
name: "dim:10"
dataType: "integer"
parent: "dim:0"
relation: "month"
description: "A dimension of Blendb. Has 12 possible values."
-
name: "dim:11"
dataType: "integer"
parent: "dim:0"
relation: "year"
description: "A dimension of Blendb. Has 1 possible value."
-
name: "enumtype:1"
values:
- "test_4"
- "test_5"
- "test_6"
- "string"
-
name: "enumtype:2"
values:
- "test_7"
- "test_8"
-
name: "enumtype:3"
values:
- "test_9"
-
name: "met:2"
dataType: "integer"
aggregation: "avg"
description: "No meaning, just used for test"
-
name: "met:3"
dataType: "integer"
aggregation: "sum"
description: "No meaning, just used for test"
-
name: "met:4"
dataType: "integer"
aggregation: "sum"
description: "No meaning, just used for test"
-
name: "met:5"
dataType: "integer"
aggregation: "avg"
description: "No meaning, just used for test"
-
name: "met:6"
dataType: "integer"
aggregation: "count"
description: "No meaning, just used for test"
-
name: "met:7"
dataType: "integer"
aggregation: "count"
description: "No meaning, just used for test"
-
name: "met:8"
dataType: "integer"
aggregation: "sum"
description: "No meaning, just used for test"
-
name: "met:9"
dataType: "integer"
aggregation: "count"
description: "No meaning, just used for test"
-
name: "met:10"
dataType: "integer"
aggregation: "max"
description: "No meaning, just used for test"
-
name: "met:11"
dataType: "integer"
aggregation: "min"
description: "No meaning, just used for test"
-
name: "source_1"
description: "source with 2 entries"
fields:
-
name: "fields:0"
description: "first entry"
dataType: "enumtype"
enumType: "enumtype:0"
-
name: "fields:1"
description: "second entry"
dataType: "string"
-
name: "source_2"
description: "source with one entry and undefined dataType"
fields:
-
name: "fields:0"
description: "first entry"
dataType: "string"
-
name: "source_3"
description: "source with one entry and without description"
fields:
-
name: "fields:0"
dataType: "string"
-
name: "source_4"
description: "source with all core types from blendb"
fields:
-
name: "fields:0"
description: "first entry"
dataType: "integer"
-
name: "fields:1"
description: "second entry"
dataType: "float"
-
name: "fields:2"
description: "third entry"
dataType: "string"
-
name: "fields:3"
description: "fourth entry"
dataType: "boolean"
-
name: "fields:4"
description: "fifth entry"
dataType: "date"
...@@ -3,76 +3,71 @@ ...@@ -3,76 +3,71 @@
# so this example file in fact is the CI test file # so this example file in fact is the CI test file
views: views:
links: links:
- config/ci_views.yaml.example - config/market_views.yaml.example
obj: obj:
- -
alias: "View 0" alias: "Seller"
data: "test/postgres/fixtures/view0.json" data: "test/postgres/fixtures/seller.json"
origin: true origin: true
dimensions: dimensions:
- "dim:0" - "dim:seller:name"
- "dim:7" - "dim:seller:sex"
- "dim:seller:cpf"
- "dim:seller:id"
- "dim:seller:status"
metrics: metrics:
- "met:0" - "met:seller:avg:age"
- "met:1" - "met:seller:max:age"
- "met:2" - "met:seller:min:age"
- "met:10" - "met:seller:count:age"
metrics: metrics:
links: links:
- config/ci_metrics.yaml.example - config/market_metrics.yaml.example
- config/ci_metrics_1.yaml.example
obj: obj:
- -
name: "met:0" name: "met:seller:avg:age"
dataType: "integer" dataType: "float"
aggregation: "sum"
description: "No meaning, just used for test"
-
name: "met:1"
dataType: "integer"
aggregation: "avg" aggregation: "avg"
description: "No meaning, just used for test" description: "The seller average age"
dimensions: dimensions:
links: links:
- config/ci_dimensions.yaml.example - config/market_dimensions.yaml.example
obj: obj:
- -
name: "dim:0" name: "dim:seller:name"
dataType: "date" dataType: "string"
description: "A dimension of Blendb. Has 5 possible values." description: "Name of the seller from market"
-
name: "dim:1"
dataType: "date"
description: "A dimension of Blendb. Has 5 possible values."
enumTypes: enumTypes:
links: links:
- config/ci_enumtypes.yaml.example - config/market_enum.yaml.example
obj: obj:
- - []
name: "enumtype:0"
values:
- "male"
- "female"
- "binary"
- "undecided"
sources: sources:
links: links:
- config/ci_sources.yaml.example - config/market_sources.yaml.example
obj: obj:
- -
name: "source_0" name: "Seller"
description: "source with 3 entries" description: "Market worker"
fields: fields:
- -
name: "fields:0" name: "name"
description: "first entry" description: "Seller name"
dataType: "string"
-
name: "fields:1"
description: "second entry"
dataType: "string" dataType: "string"
- -
name: "fields:2" name: "age"
description: "third entry" description: "Seller age"
dataType: "integer"
-
name: "sex"
description: "Seller sex"
enumType: "enumsex"
dataType: "enumtype"
-
name: "CPF"
description: "Seller CPF"
dataType: "string" dataType: "string"
-
name: "id"
description: "Seller id"
dataType: "integer"
-
alias: "View 1"
data: "test/postgres/fixtures/view1.json"
origin: true
dimensions:
- "dim:1"
- "dim:8"
metrics:
- "met:3"
- "met:4"
-
alias: "View 2"
data: "test/postgres/fixtures/view2.json"
origin: true
dimensions:
- "dim:2"
metrics:
- "met:5"
- "met:6"
- "met:11"
-
alias: "View 3"
data: "test/postgres/fixtures/view3.json"
origin: true
dimensions:
- "dim:2"
- "dim:3"
- "dim:4"
-
alias: "View 4"
data: "test/postgres/fixtures/view4.json"
origin: true
dimensions:
- "dim:2"
- "dim:7"
- "dim:8"
-
alias: "View 5"
data: "test/postgres/fixtures/view5.json"
origin: true
dimensions:
- "dim:3"
metrics:
- "met:7"
-
alias: "View 6"
data: "test/postgres/fixtures/view6.json"
origin: true
dimensions:
- "dim:4"
metrics:
- "met:8"
-
alias: "View 7"
data: "test/postgres/fixtures/view7.json"
origin: true
dimensions:
- "dim:4"
- "dim:5"
- "dim:6"
-
alias: "View 8"
data: "test/postgres/fixtures/view8.json"
origin: true
dimensions:
- "dim:5"
- "dim:6"
metrics:
- "met:9"
-
alias: "view 9"
data: "test/postgres/fixtures/view9.json"
origin: false
dimensions:
- "dim:2"
metrics:
- "met:5"
- "met:6"
- "met:7"
clauses:
- "dim:2!=1"
-
name: "dim:seller:name"
dataType: "string"
description: "The name of the seller from market"
- -
name: "dim:seller:sex" name: "dim:seller:sex"
dataType: "enumtype" dataType: "enumtype"
...@@ -8,9 +12,10 @@ ...@@ -8,9 +12,10 @@
dataType: "string" dataType: "string"
description: "CPF of the seller from market" description: "CPF of the seller from market"
- -
name: "dim:seller:id" name: "dim:seller:status"
dataType: "integer" dataType: "enumtype"
description: "id of the seller from market" enumType: "workingStatus"
description: "The status of the seller from market"
- -
name: "dim:product:name" name: "dim:product:name"
dataType: "string" dataType: "string"
...@@ -19,10 +24,6 @@ ...@@ -19,10 +24,6 @@
name: "dim:product:validity" name: "dim:product:validity"
dataType: "date" dataType: "date"
description: "Validity of the product from market" description: "Validity of the product from market"
-
name: "dim:product:id"
dataType: "integer"
description: "id of the product from market"
- -
name: "dim:client:name" name: "dim:client:name"
dataType: "string" dataType: "string"
...@@ -31,24 +32,16 @@ ...@@ -31,24 +32,16 @@
name: "dim:client:cpf" name: "dim:client:cpf"
dataType: "string" dataType: "string"
description: "CPF of the client from market" description: "CPF of the client from market"
-
name: "dim:client:id"
dataType: "integer"
description: "id of the client from market"
- -
name: "dim:sell:registered" name: "dim:sell:registered"
dataType: "boolean" dataType: "boolean"
description: "Check if the client is registered" description: "Check if the client is registered"
-
name: "dim:sell:product.id"
dataType: "integer"
description: "id of the product from market"
- -
name: "dim:sell:seller.id" name: "dim:seller:id"
dataType: "integer" dataType: "integer"
description: "id of the seller from market" description: "id of the seller from market"
- -
name: "dim:sell:client.id" name: "dim:client:id"
dataType: "integer" dataType: "integer"
description: "id of the client from market" description: "id of the client from market"
- -
...@@ -58,28 +51,17 @@ ...@@ -58,28 +51,17 @@
- -
name: "dim:buyout:datein" name: "dim:buyout:datein"
dataType: "date" dataType: "date"
description: "Date of the buyout was realized" description: "Date of the buyout was realized"
- -
name: "dim:buyout:provider.id" name: "dim:product:id"
dataType: "integer"
description: "id of the provider from market"
-
name: "dim:buyout:product.id"
dataType: "integer" dataType: "integer"
description: "id of the product from market" description: "id of the product from market"
- -
name: "dim:provider:name" name: "dim:provider:name"
dataType: "string" dataType: "string"
description: "Name of the provider from market" description: "Name of the provider from market"
- -
name: "dim:provider:id" name: "dim:provider:id"
dataType: "integer"
description: "id of the provider from market"
-
name: "dim:distribute:provider.id"
dataType: "string" dataType: "string"
description: "id of the provider from market" description: "id of the provider from market"
-
name: "dim:distribute:product.id"
dataType: "string"
description: "id of the product from market"
...@@ -5,4 +5,13 @@ ...@@ -5,4 +5,13 @@
- "female" - "female"
- "nonbinary" - "nonbinary"
- "undecided" - "undecided"
-
name: "workingStatus"
values:
- "active"
- "inactive"
- "vacation"
- "sick leave"
- "maternity leave"
...@@ -4,13 +4,14 @@ views: ...@@ -4,13 +4,14 @@ views:
obj: obj:
- -
alias: "Seller" alias: "Seller"
data: "test/postgres/fixtures/view10.json" data: "test/postgres/fixtures/seller.json"
origin: true origin: true
dimensions: dimensions:
- "dim:seller:name" - "dim:seller:name"
- "dim:seller:sex" - "dim:seller:sex"
- "dim:seller:cpf" - "dim:seller:cpf"
- "dim:seller:id" - "dim:seller:id"
- "dim:seller:status"
metrics: metrics:
- "met:seller:avg:age" - "met:seller:avg:age"
- "met:seller:max:age" - "met:seller:max:age"
......
-
name: "met:seller:avg:age"
dataType: "float"
aggregation: "avg"
description: "The seller average age"
- -
name: "met:seller:max:age" name: "met:seller:max:age"
dataType: "integer" dataType: "integer"
......
- -
alias: "Product" alias: "Product"
data: "test/postgres/fixtures/view11.json" data: "test/postgres/fixtures/product.json"
origin: true origin: true
dimensions: dimensions:
- "dim:product:name" - "dim:product:name"
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
- "met:product:min:priceout" - "met:product:min:priceout"
- -
alias: "Client" alias: "Client"
data: "test/postgres/fixtures/view12.json" data: "test/postgres/fixtures/client.json"
origin: true origin: true
dimensions: dimensions:
- "dim:client:name" - "dim:client:name"
...@@ -23,13 +23,13 @@ ...@@ -23,13 +23,13 @@
- "dim:client:id" - "dim:client:id"
- -
alias: "Sell" alias: "Sell"
data: "test/postgres/fixtures/view13.json" data: "test/postgres/fixtures/sell.json"
origin: true origin: true
dimensions: dimensions:
- "dim:sell:registered" - "dim:sell:registered"
- "dim:sell:product.id" - "dim:product:id"
- "dim:sell:seller.id" - "dim:seller:id"
- "dim:sell:client.id" - "dim:client:id"
- "dim:sell:datein" - "dim:sell:datein"
metrics: metrics:
- "met:sell:sum:quantity" - "met:sell:sum:quantity"
...@@ -37,27 +37,38 @@ ...@@ -37,27 +37,38 @@
- "met:sell:count:quantity" - "met:sell:count:quantity"
- -
alias: "Buyout" alias: "Buyout"
data: "test/postgres/fixtures/view14.json" data: "test/postgres/fixtures/buyout.json"
origin: true origin: true
dimensions: dimensions:
- "dim:buyout:datein" - "dim:buyout:datein"
- "dim:buyout:provider.id" - "dim:provider:id"
- "dim:buyout:product.id" - "dim:product:id"
metrics: metrics:
- "met:buyout:avg:quantity" - "met:buyout:avg:quantity"
- "met:buyout:max:quantity" - "met:buyout:max:quantity"
- "met:buyout:min:quantity" - "met:buyout:min:quantity"
- -
alias: "Provider" alias: "Provider"
data: "test/postgres/fixtures/view15.json" data: "test/postgres/fixtures/provider.json"
origin: true origin: true
dimensions: dimensions:
- "dim:provider:name" - "dim:provider:name"
- "dim:provider:id" - "dim:provider:id"
- -
alias: "Distribute" alias: "Distribute"
data: "test/postgres/fixtures/view16.json" data: "test/postgres/fixtures/distribute.json"
origin: true origin: true
dimensions: dimensions:
- "dim:distribute:provider.id" - "dim:provider:id"
- "dim:distribute:product.id" - "dim:product:id"
-
alias: "ActiveSeller"
data: "test/postgres/fixtures/activeseller.json"
origin: true
dimensions:
- "dim:seller:name"
- "dim:seller:status"
metrics:
- "met:seller:max:age"
clauses:
- "dim:seller:status==active"
This diff is collapsed.
This diff is collapsed.
...@@ -99,15 +99,18 @@ export class CollectCtrl { ...@@ -99,15 +99,18 @@ export class CollectCtrl {
}, },
"boolean": function(value: any) { "boolean": function(value: any) {
let test: string = value; let test = typeof(value);
test = test.toLocaleLowerCase(); if(test === "boolean"){
if (test === "true" || test === "false"){
return true; return true;
} }else{
let test: string = value;
else{ test = test.toLocaleLowerCase();
return false; if (test === "true" || test === "false"){
} return true;
}else{
return false;
}
}
} }
}; };
...@@ -126,7 +129,10 @@ export class CollectCtrl { ...@@ -126,7 +129,10 @@ export class CollectCtrl {
for (let i = 0; i < fields.length; i++){ for (let i = 0; i < fields.length; i++){
data[i] = req.body[fields[i].name]; data[i] = req.body[fields[i].name];
if (!data[i]){ // check if the data is empty, however since data may be
// true/false, it must guarantee that it isn't a boolean
// then it'll test if it's empty
if (!(typeof(data[i]) === "boolean") && !data[i]){
throw new Error( throw new Error(
"The '" + fields[i].name + "' wasn't informed on json"); "The '" + fields[i].name + "' wasn't informed on json");
} }
...@@ -158,13 +164,7 @@ export class CollectCtrl { ...@@ -158,13 +164,7 @@ export class CollectCtrl {
"The value '" + data[i] + "' from '" + fields[i].name + "The value '" + data[i] + "' from '" + fields[i].name +
"' isn't a type " + [EnumHandler.stringfyDataType(fields[i].dataType)]); "' isn't a type " + [EnumHandler.stringfyDataType(fields[i].dataType)]);
} }
} }
// undefined DataType
else{
throw new Error(
"The value '" + data[i] + "' from '" + fields[i].name +
"' isn't listed on " + fields[i].enumType);
}
} }
} }
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
import * as request from "supertest"; import * as request from "supertest";
import { expect } from "chai"; import { expect } from "chai";
import * as server from "../../main"; import * as server from "../../main";
import { dataCtrlScenario as tests } from "../../../test/scenario"; import { dataCtrlScenario as tests } from "../../../test/scenario";
import { Query } from "../../common/query"; import { Query } from "../../common/query";
...@@ -53,7 +52,8 @@ describe("API data controller", () => { ...@@ -53,7 +52,8 @@ describe("API data controller", () => {
.expect((res: any) => { .expect((res: any) => {