@vizabi/reader-ddfcsv 4.5.3 → 4.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nyc_output/574fe7f0-58f6-4de2-9524-16e72b784218.json +1 -0
- package/.nyc_output/9aede69f-00e6-432d-bdeb-2c9f4084a6dc.json +1 -0
- package/.nyc_output/processinfo/574fe7f0-58f6-4de2-9524-16e72b784218.json +1 -0
- package/.nyc_output/processinfo/9aede69f-00e6-432d-bdeb-2c9f4084a6dc.json +1 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/LICENSE +0 -0
- package/README.md +2 -2
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +161 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +210 -0
- package/coverage/src/ddf-csv.ts.html +2866 -0
- package/coverage/src/ddfcsv-error.ts.html +148 -0
- package/coverage/src/ddfcsv-reader.ts.html +538 -0
- package/coverage/src/file-readers/backend-file-reader.ts.html +175 -0
- package/coverage/src/file-readers/github-path-adapter.ts.html +244 -0
- package/coverage/src/file-readers/index.html +131 -0
- package/coverage/src/index.html +176 -0
- package/coverage/src/index.ts.html +145 -0
- package/coverage/src/interfaces.ts.html +196 -0
- package/coverage/src/resource-selection-optimizer/in-clause-under-conjunction.ts.html +745 -0
- package/coverage/src/resource-selection-optimizer/index.html +131 -0
- package/coverage/src/resource-selection-optimizer/index.ts.html +118 -0
- package/coverage/src/test-cases/concepts.ts.html +166 -0
- package/coverage/src/test-cases/entities.ts.html +241 -0
- package/coverage/src/test-cases/index.html +131 -0
- package/dist/reader-ddfcsv.js +15 -1
- package/dist/reader-ddfcsv.js.map +1 -0
- package/dist/stats.html +4950 -0
- package/icon.png +0 -0
- package/lib/src/ddf-csv.d.ts +0 -0
- package/lib/src/ddf-csv.js +13 -14
- package/lib/src/ddf-csv.js.map +1 -1
- package/lib/src/ddfcsv-error.d.ts +0 -0
- package/lib/src/ddfcsv-error.js +0 -0
- package/lib/src/ddfcsv-error.js.map +0 -0
- package/lib/src/ddfcsv-reader.d.ts +0 -0
- package/lib/src/ddfcsv-reader.js +5 -5
- package/lib/src/ddfcsv-reader.js.map +1 -1
- package/lib/src/file-readers/backend-file-reader.d.ts +0 -0
- package/lib/src/file-readers/backend-file-reader.js +0 -0
- package/lib/src/file-readers/backend-file-reader.js.map +0 -0
- package/lib/src/file-readers/github-path-adapter.d.ts +0 -0
- package/lib/src/file-readers/github-path-adapter.js +0 -0
- package/lib/src/file-readers/github-path-adapter.js.map +0 -0
- package/lib/src/index.d.ts +0 -0
- package/lib/src/index.js +2 -2
- package/lib/src/index.js.map +0 -0
- package/lib/src/interfaces.d.ts +0 -0
- package/lib/src/interfaces.js +0 -0
- package/lib/src/interfaces.js.map +0 -0
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +0 -0
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js +16 -17
- package/lib/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
- package/lib/src/resource-selection-optimizer/index.d.ts +0 -0
- package/lib/src/resource-selection-optimizer/index.js +2 -2
- package/lib/src/resource-selection-optimizer/index.js.map +1 -1
- package/lib-web/src/ddf-csv.d.ts +0 -0
- package/lib-web/src/ddf-csv.js +30 -34
- package/lib-web/src/ddf-csv.js.map +1 -1
- package/lib-web/src/ddfcsv-error.d.ts +0 -0
- package/lib-web/src/ddfcsv-error.js +5 -9
- package/lib-web/src/ddfcsv-error.js.map +1 -1
- package/lib-web/src/ddfcsv-reader.d.ts +0 -0
- package/lib-web/src/ddfcsv-reader.js +16 -19
- package/lib-web/src/ddfcsv-reader.js.map +1 -1
- package/lib-web/src/file-readers/frontend-file-reader.d.ts +0 -0
- package/lib-web/src/file-readers/frontend-file-reader.js +1 -5
- package/lib-web/src/file-readers/frontend-file-reader.js.map +1 -1
- package/lib-web/src/file-readers/github-path-adapter.d.ts +0 -0
- package/lib-web/src/file-readers/github-path-adapter.js +1 -4
- package/lib-web/src/file-readers/github-path-adapter.js.map +1 -1
- package/lib-web/src/index-web.d.ts +0 -0
- package/lib-web/src/index-web.js +9 -14
- package/lib-web/src/index-web.js.map +1 -1
- package/lib-web/src/interfaces.d.ts +0 -0
- package/lib-web/src/interfaces.js +1 -2
- package/lib-web/src/interfaces.js.map +0 -0
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.d.ts +0 -0
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js +12 -17
- package/lib-web/src/resource-selection-optimizer/in-clause-under-conjunction.js.map +1 -1
- package/lib-web/src/resource-selection-optimizer/index.d.ts +0 -0
- package/lib-web/src/resource-selection-optimizer/index.js +4 -7
- package/lib-web/src/resource-selection-optimizer/index.js.map +1 -1
- package/package.json +93 -129
- package/rollup.config.mjs +30 -0
- package/scripts/set-own-version.js +0 -0
- package/src/ddf-csv.ts +927 -927
- package/src/ddfcsv-error.ts +0 -0
- package/src/ddfcsv-reader.ts +151 -151
- package/src/file-readers/backend-file-reader.ts +0 -0
- package/src/file-readers/frontend-file-reader.ts +0 -0
- package/src/file-readers/github-path-adapter.ts +0 -0
- package/src/index-web.ts +0 -0
- package/src/index.ts +0 -0
- package/src/interfaces.ts +0 -0
- package/src/resource-selection-optimizer/in-clause-under-conjunction.ts +220 -220
- package/src/resource-selection-optimizer/index.ts +11 -11
- package/src/test-cases/concepts.ts +0 -0
- package/src/test-cases/entities.ts +52 -52
- package/test/assets-fixtures/world-50m.json +0 -0
- package/test/assets.spec.ts +0 -0
- package/test/common.ts +1 -1
- package/test/definition/concepts-definition.spec.ts +0 -0
- package/test/definition/datapoints-definition.spec.ts +1 -1
- package/test/definition/entities-definition.spec.ts +264 -264
- package/test/definition/schema-definition.spec.ts +0 -0
- package/test/diagnostics.spec.ts +0 -0
- package/test/features-service.spec.ts +95 -95
- package/test/high-load.spec.ts +0 -0
- package/test/main.spec.ts +0 -0
- package/test/multi-instances.spec.ts +0 -0
- package/test/result-fixtures/datapoints-assets.json +0 -0
- package/test/result-fixtures/in-clause-under-conjunction-1.json +0 -0
- package/test/result-fixtures/in-clause-under-conjunction-2.json +0 -0
- package/test/result-fixtures/multi-instances/concepts-sg.json +0 -0
- package/test/result-fixtures/multi-instances/concepts-soderstornsmodellen.json +0 -0
- package/test/result-fixtures/multi-instances/datapoints-sg.json +0 -0
- package/test/result-fixtures/multi-instances/datapoints-soderstornsmodellen.json +0 -0
- package/test/result-fixtures/multi-instances/entities-sg.json +0 -0
- package/test/result-fixtures/multi-instances/entities-soderstornsmodellen.json +0 -0
- package/test/result-fixtures/multi-instances/schema-sg.json +0 -0
- package/test/result-fixtures/multi-instances/schema-soderstornsmodellen.json +0 -0
- package/test/schema.spec.ts +0 -0
- package/test/tslint.json +0 -0
- package/tsconfig-web.json +41 -41
- package/tsconfig.json +40 -37
- package/tslint.json +0 -0
- package/.travis.yml +0 -37
- package/deploy.js +0 -87
- package/dist/reader-ddfcsv-polyfill.js +0 -2
- package/dist/reader-ddfcsv-polyfill.js.map +0 -1
- package/test/mocha.opts +0 -7
|
@@ -1,264 +1,264 @@
|
|
|
1
|
-
import 'mocha';
|
|
2
|
-
import * as chai from 'chai';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
BASE_PATH,
|
|
6
|
-
expectPromiseRejection,
|
|
7
|
-
GLOBALIS_PATH,
|
|
8
|
-
selectKeyClauseContainsUnavailableItems,
|
|
9
|
-
selectKeyClauseMustHaveOnly1Item,
|
|
10
|
-
selectValueClauseContainsUnavailableItems1,
|
|
11
|
-
WS_TESTING_PATH
|
|
12
|
-
} from '../common';
|
|
13
|
-
import { getDDFCsvReaderObject } from '../../src/index';
|
|
14
|
-
import {
|
|
15
|
-
CONCEPT_TYPE_ENTITY_DOMAIN,
|
|
16
|
-
CONCEPT_TYPE_ENTITY_SET,
|
|
17
|
-
isEntityDomainOrSet,
|
|
18
|
-
RESERVED_CONCEPT,
|
|
19
|
-
RESERVED_CONCEPT_TYPE,
|
|
20
|
-
RESERVED_DOMAIN,
|
|
21
|
-
RESERVED_DRILL_UP
|
|
22
|
-
} from '@vizabi/ddf-query-validator';
|
|
23
|
-
import { testsDescriptors, initData } from '../../src/test-cases/entities';
|
|
24
|
-
|
|
25
|
-
const expect = chai.expect;
|
|
26
|
-
|
|
27
|
-
describe('Entities definition errors in query', () => {
|
|
28
|
-
const descriptions = keys(testsDescriptors);
|
|
29
|
-
|
|
30
|
-
for (const description of descriptions) {
|
|
31
|
-
describe(description, () => {
|
|
32
|
-
for (const testsDescriptor of testsDescriptors[ description ]) {
|
|
33
|
-
it(testsDescriptor.itTitle, async () => {
|
|
34
|
-
const reader = getDDFCsvReaderObject();
|
|
35
|
-
|
|
36
|
-
let data;
|
|
37
|
-
|
|
38
|
-
try {
|
|
39
|
-
await reader.init(initData);
|
|
40
|
-
data = await reader.read(testsDescriptor.query);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
throw error;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
expect(data).to.not.null;
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
describe('should never happen for happy flow', () => {
|
|
52
|
-
it(`when requests '${BASE_PATH + GLOBALIS_PATH}' dataset and 'ar-SA' language`, async () => {
|
|
53
|
-
const reader = getDDFCsvReaderObject();
|
|
54
|
-
|
|
55
|
-
reader.init({});
|
|
56
|
-
|
|
57
|
-
const query = {
|
|
58
|
-
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
59
|
-
language: 'ar-SA',
|
|
60
|
-
select: {
|
|
61
|
-
key: [ 'country' ],
|
|
62
|
-
value: [ 'world_4region' ]
|
|
63
|
-
},
|
|
64
|
-
from: 'entities',
|
|
65
|
-
where: {
|
|
66
|
-
$and: [
|
|
67
|
-
{ country: { $in: [ 'usa', 'dza', 'abkh', 'afg' ] } }
|
|
68
|
-
]
|
|
69
|
-
},
|
|
70
|
-
order_by: [ 'country' ]
|
|
71
|
-
};
|
|
72
|
-
const result = await reader.read(query);
|
|
73
|
-
expect(result.length).to.equal(4);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
it(`when requests '${BASE_PATH + GLOBALIS_PATH}' dataset without 'en' language in datapackage.json`, async () => {
|
|
77
|
-
const reader = getDDFCsvReaderObject();
|
|
78
|
-
|
|
79
|
-
reader.init({});
|
|
80
|
-
|
|
81
|
-
const query = {
|
|
82
|
-
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
83
|
-
from: 'entities',
|
|
84
|
-
language: 'test',
|
|
85
|
-
select: {
|
|
86
|
-
key: [ 'country' ],
|
|
87
|
-
value: [ 'world_4region', 'un_state' ]
|
|
88
|
-
},
|
|
89
|
-
order_by: [ 'country', { world_4region: -1 } ]
|
|
90
|
-
};
|
|
91
|
-
const result = await reader.read(query);
|
|
92
|
-
|
|
93
|
-
expect(result.length).to.equal(273);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it(`when requests only one column '${BASE_PATH + GLOBALIS_PATH}' dataset`, async () => {
|
|
97
|
-
const reader = getDDFCsvReaderObject();
|
|
98
|
-
|
|
99
|
-
reader.init({});
|
|
100
|
-
|
|
101
|
-
const query = {
|
|
102
|
-
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
103
|
-
language: 'ar-SA',
|
|
104
|
-
select: {
|
|
105
|
-
key: [ 'country' ]
|
|
106
|
-
},
|
|
107
|
-
from: 'entities',
|
|
108
|
-
where: {
|
|
109
|
-
$and: [
|
|
110
|
-
{ country: { $in: [ 'usa', 'dza', 'abkh', 'afg' ] } }
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
const result = await reader.read(query);
|
|
115
|
-
|
|
116
|
-
expect(result.length).to.equal(4);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('when requests entities with where clause', async () => {
|
|
120
|
-
const reader = getDDFCsvReaderObject();
|
|
121
|
-
reader.init({});
|
|
122
|
-
|
|
123
|
-
const query = {
|
|
124
|
-
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
125
|
-
where: { world_6region: '$world_6region' },
|
|
126
|
-
select: { key: [ 'country' ], value: [ 'world_6region', 'landlocked' ] },
|
|
127
|
-
from: 'entities',
|
|
128
|
-
join: {
|
|
129
|
-
$world_6region: {
|
|
130
|
-
key: 'world_6region',
|
|
131
|
-
where: {
|
|
132
|
-
rank: { $eq: 2 }
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
const result = await reader.read(query);
|
|
138
|
-
|
|
139
|
-
expect(result).to.be.deep.equal([
|
|
140
|
-
{
|
|
141
|
-
country: 'afg',
|
|
142
|
-
landlocked: 'landlocked',
|
|
143
|
-
world_6region: 'south_asia'
|
|
144
|
-
},
|
|
145
|
-
{
|
|
146
|
-
country: 'bgd',
|
|
147
|
-
landlocked: 'coastline',
|
|
148
|
-
world_6region: 'south_asia'
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
country: 'btn',
|
|
152
|
-
landlocked: 'landlocked',
|
|
153
|
-
world_6region: 'south_asia'
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
country: 'ind',
|
|
157
|
-
landlocked: 'coastline',
|
|
158
|
-
world_6region: 'south_asia'
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
country: 'lka',
|
|
162
|
-
landlocked: 'coastline',
|
|
163
|
-
world_6region: 'south_asia'
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
country: 'mdv',
|
|
167
|
-
landlocked: 'coastline',
|
|
168
|
-
world_6region: 'south_asia'
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
country: 'npl',
|
|
172
|
-
landlocked: 'landlocked',
|
|
173
|
-
world_6region: 'south_asia'
|
|
174
|
-
},
|
|
175
|
-
{
|
|
176
|
-
country: 'pak',
|
|
177
|
-
landlocked: 'coastline',
|
|
178
|
-
world_6region: 'south_asia'
|
|
179
|
-
}
|
|
180
|
-
]);
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
describe('should be produced only for \'select\' section', () => {
|
|
185
|
-
|
|
186
|
-
it('when \'key\' property has item that is absent in dataset', async () => {
|
|
187
|
-
const reader = getDDFCsvReaderObject();
|
|
188
|
-
|
|
189
|
-
reader.init({});
|
|
190
|
-
|
|
191
|
-
const query = {
|
|
192
|
-
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
193
|
-
select: {
|
|
194
|
-
key: [ 'failed_concept' ],
|
|
195
|
-
value: [ 'company_scale', 'english_speaking' ]
|
|
196
|
-
},
|
|
197
|
-
from: 'entities'
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
await expectPromiseRejection({
|
|
201
|
-
promiseFunction: reader.read.bind(reader),
|
|
202
|
-
args: [ query ],
|
|
203
|
-
expectedErrors: [ selectKeyClauseContainsUnavailableItems ],
|
|
204
|
-
type: 'definitions'
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
it('when \'key\' property has many items (structure error)', async () => {
|
|
209
|
-
const reader = getDDFCsvReaderObject();
|
|
210
|
-
reader.init({});
|
|
211
|
-
|
|
212
|
-
const query = {
|
|
213
|
-
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
214
|
-
from: 'entities', select: { key: [ 'geo', 'failed_concept' ] }
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
await expectPromiseRejection({
|
|
218
|
-
promiseFunction: reader.read.bind(reader),
|
|
219
|
-
args: [ query ],
|
|
220
|
-
expectedErrors: [ selectKeyClauseMustHaveOnly1Item ],
|
|
221
|
-
type: 'structure'
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
|
|
225
|
-
it('when debug mode and \'value\' property has items that is absent in dataset', async () => {
|
|
226
|
-
const reader = getDDFCsvReaderObject();
|
|
227
|
-
reader.init({});
|
|
228
|
-
|
|
229
|
-
const query = {
|
|
230
|
-
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
231
|
-
from: 'entities',
|
|
232
|
-
debug: true,
|
|
233
|
-
select: {
|
|
234
|
-
key: [ 'company' ],
|
|
235
|
-
value: [ 'failed_concept', 'english_speaking', 'company_scale', 'failed_concept2', 'lines_of_code' ]
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
await expectPromiseRejection({
|
|
240
|
-
promiseFunction: reader.read.bind(reader),
|
|
241
|
-
args: [ query ],
|
|
242
|
-
expectedErrors: [ selectValueClauseContainsUnavailableItems1 ],
|
|
243
|
-
type: 'definitions'
|
|
244
|
-
});
|
|
245
|
-
});
|
|
246
|
-
|
|
247
|
-
it('when \'value\' property has items that is absent in dataset', async () => {
|
|
248
|
-
const reader = getDDFCsvReaderObject();
|
|
249
|
-
reader.init({});
|
|
250
|
-
|
|
251
|
-
const query = {
|
|
252
|
-
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
253
|
-
from: 'entities',
|
|
254
|
-
select: {
|
|
255
|
-
key: [ 'company' ],
|
|
256
|
-
value: [ 'failed_concept', 'english_speaking', 'company_scale', 'failed_concept2', 'lines_of_code' ]
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const result = await reader.read(query);
|
|
261
|
-
expect(result).to.be.deep.equal([]);
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
});
|
|
1
|
+
import 'mocha';
|
|
2
|
+
import * as chai from 'chai';
|
|
3
|
+
import keys from 'lodash-es/keys';
|
|
4
|
+
import {
|
|
5
|
+
BASE_PATH,
|
|
6
|
+
expectPromiseRejection,
|
|
7
|
+
GLOBALIS_PATH,
|
|
8
|
+
selectKeyClauseContainsUnavailableItems,
|
|
9
|
+
selectKeyClauseMustHaveOnly1Item,
|
|
10
|
+
selectValueClauseContainsUnavailableItems1,
|
|
11
|
+
WS_TESTING_PATH
|
|
12
|
+
} from '../common';
|
|
13
|
+
import { getDDFCsvReaderObject } from '../../src/index';
|
|
14
|
+
import {
|
|
15
|
+
CONCEPT_TYPE_ENTITY_DOMAIN,
|
|
16
|
+
CONCEPT_TYPE_ENTITY_SET,
|
|
17
|
+
isEntityDomainOrSet,
|
|
18
|
+
RESERVED_CONCEPT,
|
|
19
|
+
RESERVED_CONCEPT_TYPE,
|
|
20
|
+
RESERVED_DOMAIN,
|
|
21
|
+
RESERVED_DRILL_UP
|
|
22
|
+
} from '@vizabi/ddf-query-validator';
|
|
23
|
+
import { testsDescriptors, initData } from '../../src/test-cases/entities';
|
|
24
|
+
|
|
25
|
+
const expect = chai.expect;
|
|
26
|
+
|
|
27
|
+
describe('Entities definition errors in query', () => {
|
|
28
|
+
const descriptions = keys(testsDescriptors);
|
|
29
|
+
|
|
30
|
+
for (const description of descriptions) {
|
|
31
|
+
describe(description, () => {
|
|
32
|
+
for (const testsDescriptor of testsDescriptors[ description ]) {
|
|
33
|
+
it(testsDescriptor.itTitle, async () => {
|
|
34
|
+
const reader = getDDFCsvReaderObject();
|
|
35
|
+
|
|
36
|
+
let data;
|
|
37
|
+
|
|
38
|
+
try {
|
|
39
|
+
await reader.init(initData);
|
|
40
|
+
data = await reader.read(testsDescriptor.query);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
expect(data).to.not.null;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('should never happen for happy flow', () => {
|
|
52
|
+
it(`when requests '${BASE_PATH + GLOBALIS_PATH}' dataset and 'ar-SA' language`, async () => {
|
|
53
|
+
const reader = getDDFCsvReaderObject();
|
|
54
|
+
|
|
55
|
+
reader.init({});
|
|
56
|
+
|
|
57
|
+
const query = {
|
|
58
|
+
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
59
|
+
language: 'ar-SA',
|
|
60
|
+
select: {
|
|
61
|
+
key: [ 'country' ],
|
|
62
|
+
value: [ 'world_4region' ]
|
|
63
|
+
},
|
|
64
|
+
from: 'entities',
|
|
65
|
+
where: {
|
|
66
|
+
$and: [
|
|
67
|
+
{ country: { $in: [ 'usa', 'dza', 'abkh', 'afg' ] } }
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
order_by: [ 'country' ]
|
|
71
|
+
};
|
|
72
|
+
const result = await reader.read(query);
|
|
73
|
+
expect(result.length).to.equal(4);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it(`when requests '${BASE_PATH + GLOBALIS_PATH}' dataset without 'en' language in datapackage.json`, async () => {
|
|
77
|
+
const reader = getDDFCsvReaderObject();
|
|
78
|
+
|
|
79
|
+
reader.init({});
|
|
80
|
+
|
|
81
|
+
const query = {
|
|
82
|
+
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
83
|
+
from: 'entities',
|
|
84
|
+
language: 'test',
|
|
85
|
+
select: {
|
|
86
|
+
key: [ 'country' ],
|
|
87
|
+
value: [ 'world_4region', 'un_state' ]
|
|
88
|
+
},
|
|
89
|
+
order_by: [ 'country', { world_4region: -1 } ]
|
|
90
|
+
};
|
|
91
|
+
const result = await reader.read(query);
|
|
92
|
+
|
|
93
|
+
expect(result.length).to.equal(273);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it(`when requests only one column '${BASE_PATH + GLOBALIS_PATH}' dataset`, async () => {
|
|
97
|
+
const reader = getDDFCsvReaderObject();
|
|
98
|
+
|
|
99
|
+
reader.init({});
|
|
100
|
+
|
|
101
|
+
const query = {
|
|
102
|
+
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
103
|
+
language: 'ar-SA',
|
|
104
|
+
select: {
|
|
105
|
+
key: [ 'country' ]
|
|
106
|
+
},
|
|
107
|
+
from: 'entities',
|
|
108
|
+
where: {
|
|
109
|
+
$and: [
|
|
110
|
+
{ country: { $in: [ 'usa', 'dza', 'abkh', 'afg' ] } }
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
const result = await reader.read(query);
|
|
115
|
+
|
|
116
|
+
expect(result.length).to.equal(4);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('when requests entities with where clause', async () => {
|
|
120
|
+
const reader = getDDFCsvReaderObject();
|
|
121
|
+
reader.init({});
|
|
122
|
+
|
|
123
|
+
const query = {
|
|
124
|
+
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
125
|
+
where: { world_6region: '$world_6region' },
|
|
126
|
+
select: { key: [ 'country' ], value: [ 'world_6region', 'landlocked' ] },
|
|
127
|
+
from: 'entities',
|
|
128
|
+
join: {
|
|
129
|
+
$world_6region: {
|
|
130
|
+
key: 'world_6region',
|
|
131
|
+
where: {
|
|
132
|
+
rank: { $eq: 2 }
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
const result = await reader.read(query);
|
|
138
|
+
|
|
139
|
+
expect(result).to.be.deep.equal([
|
|
140
|
+
{
|
|
141
|
+
country: 'afg',
|
|
142
|
+
landlocked: 'landlocked',
|
|
143
|
+
world_6region: 'south_asia'
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
country: 'bgd',
|
|
147
|
+
landlocked: 'coastline',
|
|
148
|
+
world_6region: 'south_asia'
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
country: 'btn',
|
|
152
|
+
landlocked: 'landlocked',
|
|
153
|
+
world_6region: 'south_asia'
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
country: 'ind',
|
|
157
|
+
landlocked: 'coastline',
|
|
158
|
+
world_6region: 'south_asia'
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
country: 'lka',
|
|
162
|
+
landlocked: 'coastline',
|
|
163
|
+
world_6region: 'south_asia'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
country: 'mdv',
|
|
167
|
+
landlocked: 'coastline',
|
|
168
|
+
world_6region: 'south_asia'
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
country: 'npl',
|
|
172
|
+
landlocked: 'landlocked',
|
|
173
|
+
world_6region: 'south_asia'
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
country: 'pak',
|
|
177
|
+
landlocked: 'coastline',
|
|
178
|
+
world_6region: 'south_asia'
|
|
179
|
+
}
|
|
180
|
+
]);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe('should be produced only for \'select\' section', () => {
|
|
185
|
+
|
|
186
|
+
it('when \'key\' property has item that is absent in dataset', async () => {
|
|
187
|
+
const reader = getDDFCsvReaderObject();
|
|
188
|
+
|
|
189
|
+
reader.init({});
|
|
190
|
+
|
|
191
|
+
const query = {
|
|
192
|
+
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
193
|
+
select: {
|
|
194
|
+
key: [ 'failed_concept' ],
|
|
195
|
+
value: [ 'company_scale', 'english_speaking' ]
|
|
196
|
+
},
|
|
197
|
+
from: 'entities'
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
await expectPromiseRejection({
|
|
201
|
+
promiseFunction: reader.read.bind(reader),
|
|
202
|
+
args: [ query ],
|
|
203
|
+
expectedErrors: [ selectKeyClauseContainsUnavailableItems ],
|
|
204
|
+
type: 'definitions'
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
it('when \'key\' property has many items (structure error)', async () => {
|
|
209
|
+
const reader = getDDFCsvReaderObject();
|
|
210
|
+
reader.init({});
|
|
211
|
+
|
|
212
|
+
const query = {
|
|
213
|
+
repositoryPath: BASE_PATH + GLOBALIS_PATH + '/master-HEAD',
|
|
214
|
+
from: 'entities', select: { key: [ 'geo', 'failed_concept' ] }
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
await expectPromiseRejection({
|
|
218
|
+
promiseFunction: reader.read.bind(reader),
|
|
219
|
+
args: [ query ],
|
|
220
|
+
expectedErrors: [ selectKeyClauseMustHaveOnly1Item ],
|
|
221
|
+
type: 'structure'
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
it('when debug mode and \'value\' property has items that is absent in dataset', async () => {
|
|
226
|
+
const reader = getDDFCsvReaderObject();
|
|
227
|
+
reader.init({});
|
|
228
|
+
|
|
229
|
+
const query = {
|
|
230
|
+
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
231
|
+
from: 'entities',
|
|
232
|
+
debug: true,
|
|
233
|
+
select: {
|
|
234
|
+
key: [ 'company' ],
|
|
235
|
+
value: [ 'failed_concept', 'english_speaking', 'company_scale', 'failed_concept2', 'lines_of_code' ]
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
await expectPromiseRejection({
|
|
240
|
+
promiseFunction: reader.read.bind(reader),
|
|
241
|
+
args: [ query ],
|
|
242
|
+
expectedErrors: [ selectValueClauseContainsUnavailableItems1 ],
|
|
243
|
+
type: 'definitions'
|
|
244
|
+
});
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('when \'value\' property has items that is absent in dataset', async () => {
|
|
248
|
+
const reader = getDDFCsvReaderObject();
|
|
249
|
+
reader.init({});
|
|
250
|
+
|
|
251
|
+
const query = {
|
|
252
|
+
repositoryPath: BASE_PATH + WS_TESTING_PATH + '/master-HEAD',
|
|
253
|
+
from: 'entities',
|
|
254
|
+
select: {
|
|
255
|
+
key: [ 'company' ],
|
|
256
|
+
value: [ 'failed_concept', 'english_speaking', 'company_scale', 'failed_concept2', 'lines_of_code' ]
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
const result = await reader.read(query);
|
|
261
|
+
expect(result).to.be.deep.equal([]);
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
});
|
|
File without changes
|
package/test/diagnostics.spec.ts
CHANGED
|
File without changes
|