Skip to content

Commit

Permalink
fix test due to from the scratch refactor
Browse files Browse the repository at this point in the history
to send Timestamp ISO
to take into account skipValues
to take into account Attributes will "shadow" Measures (Attr def is priority)
  • Loading branch information
mrutid committed Oct 13, 2023
1 parent 9ec8f72 commit 7639dd5
Show file tree
Hide file tree
Showing 16 changed files with 19,362 additions and 114 deletions.
19,311 changes: 19,311 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions test/deviceProvisioning/provisionDeviceTimeinstant2.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
},
{
"type": "DateTime",
"name": "TimeInstant",
"object_id": "t"
"name": "TimeInstant"

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

If you want TimeInstant MEASURE to be propagated it is a MUST DO NOT declare another measure(t)->attr(TimeInstant) mapping

}
],
"entity_type": "sensor",
Expand Down
16 changes: 8 additions & 8 deletions test/unit/ngsiv2/HTTP_reveice_measures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ describe('HTTP: Measure reception ', function () {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
json: {
humidity: '111222',
h: '111222',

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

There was a mapping provisioned (h->humidity) so "humidity" is not expected as a measure and will be shadowed by "humidity" attr.

pressure: '20',
TimeInstant: '20200222T222222'
TimeInstant: '2020-02-22T22:22:22Z'

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

stop sending stupid timestamps (4 bytes less)

},
headers: {
'fiware-service': 'smartgondor',
Expand Down Expand Up @@ -217,9 +217,9 @@ describe('HTTP: Measure reception ', function () {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
json: {
humidity: '111222',
h: '111222',
pressure: '20',
TimeInstant: '20200222T222222'
TimeInstant: '2020-02-22T22:22:22Z'
},
headers: {
'fiware-service': 'smartgondor',
Expand Down Expand Up @@ -280,7 +280,7 @@ describe('HTTP: Measure reception ', function () {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
json: {
humidity: '111222',
h: '111222',
pressure: '20'
},
headers: {
Expand All @@ -290,7 +290,7 @@ describe('HTTP: Measure reception ', function () {
qs: {
i: 'dev0130101',
k: '1234',
t: '20200222T222222'
t: '2020-02-22T22:22:22Z'
}
};
const provisionOptions = {
Expand Down Expand Up @@ -343,7 +343,7 @@ describe('HTTP: Measure reception ', function () {
url: 'http://localhost:' + config.http.port + '/iot/json',
method: 'POST',
json: {
humidity: '111222',
h: '111222',
pressure: '20'
},
headers: {
Expand All @@ -353,7 +353,7 @@ describe('HTTP: Measure reception ', function () {
qs: {
i: 'dev0130101',
k: '1234',
t: '20200222T222222'
t: '2020-02-22T22:22:22Z'
}
};
const provisionOptions = {
Expand Down
17 changes: 9 additions & 8 deletions test/unit/ngsiv2/HTTP_reveice_measures-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ describe('HTTP: Measure reception ', function () {
method: 'POST',
json: [
{
humidity: '111222',
TimeInstant: '20200222T222222'
h: '111222',
TimeInstant: '2020-02-22T22:22:22Z'
},
{
humidity: '111333',
TimeInstant: '20200222T222222'
h: '111333',
TimeInstant: '2020-02-22T22:22:22Z'
}
],
headers: {
Expand Down Expand Up @@ -254,10 +254,11 @@ describe('HTTP: Measure reception ', function () {
method: 'POST',
json: [
{
humidity: '111222'
h: '111222'

},
{
humidity: '111333'
h: '111333'
}
],
headers: {
Expand All @@ -266,8 +267,8 @@ describe('HTTP: Measure reception ', function () {
},
qs: {
i: 'dev0130101',
k: '1234',
t: '20200222T222222'
k: '1234' ,
t:'2020-02-22T22:22:22Z'
}
};
const provisionOptions = {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/MQTT_receive_measures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ describe('MQTT: Measure reception ', function () {
const values = {
humidity: '32',
temperature: '87',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:05Z'
};

mqttClient.publish('/1234/MQTT_2/attrs', JSON.stringify(values), null, function (error) {
Expand All @@ -282,7 +282,7 @@ describe('MQTT: Measure reception ', function () {
const values = {
humidity: '32',
temperature: '87',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:05Z'
};

mqttClient.publish('json/1234/MQTT_2/attrs', JSON.stringify(values), null, function (error) {
Expand Down
8 changes: 4 additions & 4 deletions test/unit/ngsiv2/MQTT_receive_measures-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,12 @@ describe('MQTT: Measure reception ', function () {
{
humidity: '32',
temperature: '87',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:05Z'
},
{
humidity: '33',
temperature: '89',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:06Z'
}
];

Expand All @@ -378,12 +378,12 @@ describe('MQTT: Measure reception ', function () {
{
humidity: '32',
temperature: '87',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:05Z'
},
{
humidity: '33',
temperature: '89',
TimeInstant: '20071103T131805'
TimeInstant: '2007-11-03T13:18:06Z'

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

minor improvement of the use case. Different times.

}
];

Expand Down
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/attribute-alias_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const config = require('./config-test.js');
const nock = require('nock');
const iotAgentLib = require('iotagent-node-lib');
const async = require('async');

const configS = require('../../../lib/configService');

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

leftover

const utils = require('../../utils');
const request = utils.request;
let contextBrokerMock;
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('Attribute alias', function () {
const values = {
humidity: '32',
temperature: '87',
tt: '20071103T131805'
tt: '2007-03-11T12:18:05.000Z'
};

mqttClient.publish('/json/1234/MQTT_2/attrs', JSON.stringify(values), null, function (error) {
Expand Down
10 changes: 3 additions & 7 deletions test/unit/ngsiv2/contextRequests/multipleMeasuresJsonTypes.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"type":"AnMQTTDevice",
"humidity":{
"type": "degrees",
"value": "32"
"value": "32"
},
"temperature":{
"type": "celsius",
"value": "87"
"value": "87"
},
"luminosity": {
"type": "Integer",
Expand All @@ -33,9 +33,5 @@
"enabled": {
"type": "Boolean",
"value": true
},
"alive": {
"type": "Null",
"value": null

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

SKIPPEP NULL

}
}
10 changes: 3 additions & 7 deletions test/unit/ngsiv2/contextRequests/multipleMeasuresJsonTypes2.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"type":"AnMQTTDevice",
"humidity":{
"type": "degrees",
"value": "33"
"value": "33"
},
"temperature":{
"type": "celsius",
"value": "89"
"value": "89"
},
"luminosity": {
"type": "Integer",
Expand All @@ -33,9 +33,5 @@
"enabled": {
"type": "Boolean",
"value": true
},
"alive": {
"type": "Null",
"value": null

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

SKIPPED NULL

}
}
10 changes: 2 additions & 8 deletions test/unit/ngsiv2/contextRequests/timeInstantMeasures.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,10 @@
"type":"sensor",
"humidity":{
"type": "percent",
"value": "111222",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002020-02-22T22:22:22"
}
}
"value": "111222"
},
"TimeInstant":{
"type": "DateTime",
"value": "+002020-02-22T22:22:22"
"value": "2020-02-22T22:22:22Z"
}
}
13 changes: 3 additions & 10 deletions test/unit/ngsiv2/contextRequests/timeInstantMeasures2.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
{
"id":"e0130101",
"type":"sensor",
"type":"sensor",
"humidity":{
"type": "percent",
"value": "111333",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002020-02-22T22:22:22"
}
}
"value": "111333"
},

"TimeInstant":{
"type": "DateTime",
"value": "+002020-02-22T22:22:22"
"value": "2020-02-22T22:22:22Z"
}
}
18 changes: 3 additions & 15 deletions test/unit/ngsiv2/contextRequests/timeInstantMeasures3.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,14 @@
"type":"sensor",
"humidity":{
"type": "percent",
"value": "111222",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002020-02-22T22:22:22"
}
}
"value": "111222"
},
"pressure":{
"type": "string",
"value": "20",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002020-02-22T22:22:22"
}
}
"value": "20"
},
"TimeInstant":{
"type": "DateTime",
"value": "+002020-02-22T22:22:22"
"value": "2020-02-22T22:22:22Z"
}
}
12 changes: 3 additions & 9 deletions test/unit/ngsiv2/contextRequests/timeInstantMeasuresB.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
{
"id":"e0130101",
"type":"sensor",
"type":"sensor",
"TimeInstant":{
"type": "DateTime",
"value": "+002020-02-22T22:22:22"
"value": "2020-02-22T22:22:22Z"
},
"humidity":{
"type": "percent",
"value": "111222",
"metadata": {
"TimeInstant": {
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002020-02-22T22:22:22"
}
}
"value": "111222"
}
}
4 changes: 2 additions & 2 deletions test/unit/ngsiv2/contextRequests/timestampAliasMeasure.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id":"Second MQTT Device",
"type":"AnMQTTDevice",
"type":"AnMQTTDevice",
"humidity":{
"type":"degrees",
"value":"32"
Expand All @@ -11,6 +11,6 @@
},
"TimeInstant":{
"type":"DateTime",
"value": "+002007-11-03T13:18:05"
"value": "2007-03-11T12:18:05.000Z"
}
}
18 changes: 3 additions & 15 deletions test/unit/ngsiv2/contextRequests/timestampMeasure.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,14 @@
"type":"AnMQTTDevice",
"humidity":{
"type": "degrees",
"value": "32",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002007-11-03T13:18:05"
}
}
"value": "32"
},
"temperature":{
"type": "celsius",
"value": "87",
"metadata": {
"TimeInstant":{
"type": "DateTime",

This comment has been minimized.

Copy link
@mrutid

mrutid Oct 13, 2023

Author Member

timestamp flag is FALSE. No metadata.

"value": "+002007-11-03T13:18:05"
}
}
"value": "87"
},
"TimeInstant":{
"type": "DateTime",
"value": "+002007-11-03T13:18:05"
"value": "2007-11-03T13:18:05Z"
}
}
Loading

0 comments on commit 7639dd5

Please sign in to comment.