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 @@
# so this example file in fact is the CI test file
views:
links:
- config/ci_views.yaml.example
- config/market_views.yaml.example
obj:
-
alias: "View 0"
data: "test/postgres/fixtures/view0.json"
alias: "Seller"
data: "test/postgres/fixtures/seller.json"
origin: true
dimensions:
- "dim:0"
- "dim:7"
- "dim:seller:name"
- "dim:seller:sex"
- "dim:seller:cpf"
- "dim:seller:id"
- "dim:seller:status"
metrics:
- "met:0"
- "met:1"
- "met:2"
- "met:10"
- "met:seller:avg:age"
- "met:seller:max:age"
- "met:seller:min:age"
- "met:seller:count:age"
metrics:
links:
- config/ci_metrics.yaml.example
- config/ci_metrics_1.yaml.example
- config/market_metrics.yaml.example
obj:
-
name: "met:0"
dataType: "integer"
aggregation: "sum"
description: "No meaning, just used for test"
-
name: "met:1"
dataType: "integer"
-
name: "met:seller:avg:age"
dataType: "float"
aggregation: "avg"
description: "No meaning, just used for test"
description: "The seller average age"
dimensions:
links:
- config/ci_dimensions.yaml.example
- config/market_dimensions.yaml.example
obj:
-
name: "dim:0"
dataType: "date"
description: "A dimension of Blendb. Has 5 possible values."
-
name: "dim:1"
dataType: "date"
description: "A dimension of Blendb. Has 5 possible values."
name: "dim:seller:name"
dataType: "string"
description: "Name of the seller from market"
enumTypes:
links:
- config/ci_enumtypes.yaml.example
- config/market_enum.yaml.example
obj:
-
name: "enumtype:0"
values:
- "male"
- "female"
- "binary"
- "undecided"
- []
sources:
links:
- config/ci_sources.yaml.example
- config/market_sources.yaml.example
obj:
-
name: "source_0"
description: "source with 3 entries"
name: "Seller"
description: "Market worker"
fields:
-
name: "fields:0"
description: "first entry"
dataType: "string"
-
name: "fields:1"
description: "second entry"
name: "name"
description: "Seller name"
dataType: "string"
-
name: "fields:2"
description: "third entry"
name: "age"
description: "Seller age"
dataType: "integer"
-
name: "sex"
description: "Seller sex"
enumType: "enumsex"
dataType: "enumtype"
-
name: "CPF"
description: "Seller CPF"
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"
dataType: "enumtype"
......@@ -8,9 +12,10 @@
dataType: "string"
description: "CPF of the seller from market"
-
name: "dim:seller:id"
dataType: "integer"
description: "id of the seller from market"
name: "dim:seller:status"
dataType: "enumtype"
enumType: "workingStatus"
description: "The status of the seller from market"
-
name: "dim:product:name"
dataType: "string"
......@@ -19,10 +24,6 @@
name: "dim:product:validity"
dataType: "date"
description: "Validity of the product from market"
-
name: "dim:product:id"
dataType: "integer"
description: "id of the product from market"
-
name: "dim:client:name"
dataType: "string"
......@@ -31,24 +32,16 @@
name: "dim:client:cpf"
dataType: "string"
description: "CPF of the client from market"
-
name: "dim:client:id"
dataType: "integer"
description: "id of the client from market"
-
name: "dim:sell:registered"
dataType: "boolean"
description: "Check if the client is registered"
-
name: "dim:sell:product.id"
dataType: "integer"
description: "id of the product from market"
description: "Check if the client is registered"
-
name: "dim:sell:seller.id"
name: "dim:seller:id"
dataType: "integer"
description: "id of the seller from market"
-
name: "dim:sell:client.id"
name: "dim:client:id"
dataType: "integer"
description: "id of the client from market"
-
......@@ -58,28 +51,17 @@
-
name: "dim:buyout:datein"
dataType: "date"
description: "Date of the buyout was realized"
description: "Date of the buyout was realized"
-
name: "dim:buyout:provider.id"
dataType: "integer"
description: "id of the provider from market"
-
name: "dim:buyout:product.id"
name: "dim:product:id"
dataType: "integer"
description: "id of the product from market"
-
name: "dim:provider:name"
dataType: "string"
description: "Name of the provider from market"
description: "Name of the provider from market"
-
name: "dim:provider:id"
dataType: "integer"
description: "id of the provider from market"
-
name: "dim:distribute:provider.id"
dataType: "string"
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 @@
- "female"
- "nonbinary"
- "undecided"
-
name: "workingStatus"
values:
- "active"
- "inactive"
- "vacation"
- "sick leave"
- "maternity leave"
......@@ -4,13 +4,14 @@ views:
obj:
-
alias: "Seller"
data: "test/postgres/fixtures/view10.json"
data: "test/postgres/fixtures/seller.json"
origin: true
dimensions:
- "dim:seller:name"
- "dim:seller:sex"
- "dim:seller:cpf"
- "dim:seller:id"
- "dim:seller:status"
metrics:
- "met:seller:avg:age"
- "met:seller:max:age"
......
-
name: "met:seller:avg:age"
dataType: "float"
aggregation: "avg"
description: "The seller average age"
-
name: "met:seller:max:age"
dataType: "integer"
......
-
alias: "Product"
data: "test/postgres/fixtures/view11.json"
data: "test/postgres/fixtures/product.json"
origin: true
dimensions:
- "dim:product:name"
......@@ -15,7 +15,7 @@
- "met:product:min:priceout"
-
alias: "Client"
data: "test/postgres/fixtures/view12.json"
data: "test/postgres/fixtures/client.json"
origin: true
dimensions:
- "dim:client:name"
......@@ -23,13 +23,13 @@
- "dim:client:id"
-
alias: "Sell"
data: "test/postgres/fixtures/view13.json"
data: "test/postgres/fixtures/sell.json"
origin: true
dimensions:
- "dim:sell:registered"
- "dim:sell:product.id"
- "dim:sell:seller.id"
- "dim:sell:client.id"
- "dim:product:id"
- "dim:seller:id"
- "dim:client:id"
- "dim:sell:datein"
metrics:
- "met:sell:sum:quantity"
......@@ -37,27 +37,38 @@
- "met:sell:count:quantity"
-
alias: "Buyout"
data: "test/postgres/fixtures/view14.json"
data: "test/postgres/fixtures/buyout.json"
origin: true
dimensions:
- "dim:buyout:datein"
- "dim:buyout:provider.id"
- "dim:buyout:product.id"
- "dim:provider:id"
- "dim:product:id"
metrics:
- "met:buyout:avg:quantity"
- "met:buyout:max:quantity"
- "met:buyout:min:quantity"
-
alias: "Provider"
data: "test/postgres/fixtures/view15.json"
data: "test/postgres/fixtures/provider.json"
origin: true
dimensions:
- "dim:provider:name"
- "dim:provider:id"
-
alias: "Distribute"
data: "test/postgres/fixtures/view16.json"
data: "test/postgres/fixtures/distribute.json"
origin: true
dimensions:
- "dim:distribute:provider.id"
- "dim:distribute:product.id"
- "dim:provider: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"
......@@ -19,7 +19,6 @@
*/
import { expect } from "chai";
import { PostgresAdapter } from "./postgres";
import { MonetAdapter, MonetConfig } from "./monet";
import { Adapter } from "../core/adapter";
......@@ -87,29 +86,12 @@ describe("Sql adapter", () => {
done();
});
});
it("should get data from join of 2 views (without selection)", (done) => {
let view = adapterScenario.noSelectionView;
it("should sort data from join of two views", (done) => {
let view = adapterScenario.sortView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(1);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
keys = keys.concat(view.dimensions.map((item) => item.name));
result.forEach((row) => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
});
done();
});
});
it("should get data from join of 2 views (with selection)", (done) => {
let view = adapterScenario.withSelectionView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(5);
expect(result).to.have.length(4);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
......@@ -119,7 +101,7 @@ describe("Sql adapter", () => {
expect(row).to.have.all.keys(keys);
});
done();
});
});
});
it("should get data from single view (with sub-dimension)", (done) => {
let view = adapterScenario.subDimensionView;
......@@ -138,8 +120,8 @@ describe("Sql adapter", () => {
done();
});
});
it("should get data from join of 4 views (with selection)", (done) => {
let view = adapterScenario.join4View;
it("should get data from join of one view", (done) => {
let view = adapterScenario.joinWithOneView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
......@@ -155,28 +137,9 @@ describe("Sql adapter", () => {
done();
});
});
it("should get data from different sub dimensions with same parent", (done) => {
let view = adapterScenario.dateView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(5);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
keys = keys.concat(view.dimensions.map((item) => item.name));
result.forEach((row) => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
expect(row).to.have.property("dim:0:year", 2017);
});
done();
});
});
it("should get data from view with all types of agreggation", (done) => {
let view = adapterScenario.aggrView;
adapter.getDataFromView(view, (err, result) => {
it("should get data from view with a single clause", (done) => {
let view = adapterScenario.filterWithEqual;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(1);
......@@ -188,22 +151,15 @@ describe("Sql adapter", () => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
});
expect(parseInt(result[0]["met:0"], 10)).to.be.equal(15);
expect(parseInt(result[0]["met:1"], 10)).to.be.equal(3);
expect(parseInt(result[0]["met:6"], 10)).to.be.equal(5);
expect(parseInt(result[0]["met:10"], 10)).to.be.equal(5);
expect(parseInt(result[0]["met:11"], 10)).to.be.equal(1);
done();
});
});
it("should get data from view when a single clause exists", (done) => {
let view = adapterScenario.clauseView;
it("should get data from reduce with the same attributes of view", (done) => {
let view = adapterScenario.reduceAsView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(1);
expect(result).to.have.length(5);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
......@@ -212,21 +168,15 @@ describe("Sql adapter", () => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
});
expect(parseInt(result[0]["met:0"], 10)).to.be.equal(1);
expect(parseInt(result[0]["met:1"], 10)).to.be.equal(1);
expect(parseInt(result[0]["met:2"], 10)).to.be.equal(1);
expect(result[0]["dim:0"].getDate()).to.be.equal(1);
done();
});
});
it("should get data from view with single clause, with more than on filter", (done) => {
let view = adapterScenario.multiFilterView;
it("should get data from join into reduce with a single clause", (done) => {
let view = adapterScenario.filterAverageBought;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");
expect(result).to.be.an("array");
expect(result).to.have.length(2);
expect(result).to.have.length(3);
expect(result[0]).to.be.an("object");
let keys: string[] = [];
keys = keys.concat(view.metrics.map((item) => item.name));
......@@ -235,43 +185,11 @@ describe("Sql adapter", () => {
expect(row).to.be.an("object");
expect(row).to.have.all.keys(keys);
});
done();
});
});
it("should get data from view with multiple clauses", (done) => {
let view = adapterScenario.multiClauseView;
adapter.getDataFromView(view, (err, result) => {
expect(err).to.be.a("null");