Skip to content

Commit

Permalink
Merge pull request #737 from telefonicaid/task/do_not_create_initial_…
Browse files Browse the repository at this point in the history
…entity

remove initial entity from mocks
  • Loading branch information
fgalan authored Aug 9, 2023
2 parents ef782f8 + 372db01 commit 6aa26c7
Show file tree
Hide file tree
Showing 18 changed files with 35 additions and 206 deletions.
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fix: update tests to not create initial entity when append mode is enabled
- Fix: update tests according new default value for appendMode
- Fix: use 'options=upsert' when update ngsiv2 CB entities and appendMode is enabled (iotagent-node-lib#956)
- Fix: do not propagate group config (timestamp and explicitAttrs) to autoprovisioned devices (at database level) (iotagent-node-lib#1377)
Expand Down
12 changes: 0 additions & 12 deletions test/unit/ngsiv2/HTTP_commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ describe('HTTP: Commands', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

iotagentMqtt.start(config, function () {
request(provisionOptions, function (error, response, body) {
done();
Expand Down Expand Up @@ -159,12 +153,6 @@ describe('HTTP: Commands with expressions', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

iotagentMqtt.start(config, function () {
request(provisionOptions, function (error, response, body) {
done();
Expand Down
6 changes: 0 additions & 6 deletions test/unit/ngsiv2/HTTP_get-configuration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ describe('HTTP: Get configuration from the devices', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

oldConfigurationFlag = config.configRetrieval;
config.configRetrieval = true;

Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/HTTP_receive_measures-test3.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down
36 changes: 6 additions & 30 deletions test/unit/ngsiv2/HTTP_reveice_measures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down Expand Up @@ -186,11 +182,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -253,11 +245,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -320,11 +308,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -387,11 +371,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -442,11 +422,7 @@ describe('HTTP: Measure reception ', function () {
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
beforeEach(function (done) {
contextBrokerUnprovMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerUnprovMock = nock('http://192.168.1.1:1026');

contextBrokerUnprovMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down
24 changes: 4 additions & 20 deletions test/unit/ngsiv2/HTTP_reveice_measures-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down Expand Up @@ -213,11 +209,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -293,11 +285,7 @@ describe('HTTP: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down Expand Up @@ -363,11 +351,7 @@ describe('HTTP: Measure reception ', function () {
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
beforeEach(function (done) {
contextBrokerUnprovMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerUnprovMock = nock('http://192.168.1.1:1026');

contextBrokerUnprovMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down
6 changes: 0 additions & 6 deletions test/unit/ngsiv2/MQTT_commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ describe('MQTT: Commands', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

iotagentMqtt.start(config, function () {
request(provisionOptions, function (error, response, body) {
done();
Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/MQTT_get-configuration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,7 @@ describe('MQTT: Get configuration from the devices', function () {
connectTimeout: 60 * 60 * 1000
});

contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

oldConfigurationFlag = config.configRetrieval;
config.configRetrieval = true;
Expand Down
12 changes: 2 additions & 10 deletions test/unit/ngsiv2/MQTT_receive_measures-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ describe('MQTT: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down Expand Up @@ -168,11 +164,7 @@ describe('MQTT: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerUnprovMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerUnprovMock = nock('http://192.168.1.1:1026');

contextBrokerUnprovMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down
12 changes: 2 additions & 10 deletions test/unit/ngsiv2/MQTT_receive_measures-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ describe('MQTT: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down Expand Up @@ -205,11 +201,7 @@ describe('MQTT: Measure reception ', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerUnprovMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerUnprovMock = nock('http://192.168.1.1:1026');

contextBrokerUnprovMock
.matchHeader('fiware-service', 'smartgondor')
Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/_subscription-management_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,7 @@ describe('Subscription management', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026', { allowUnmocked: false })
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026', { allowUnmocked: false });

iotaJson.start(config, function () {
iotAgentLib.clearAll(done);
Expand Down
12 changes: 2 additions & 10 deletions test/unit/ngsiv2/amqpBinding-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ describe('AMQP Transport binding: measures', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

async.series(
[
Expand Down Expand Up @@ -135,11 +131,7 @@ describe('AMQP Transport binding: measures', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerUnprovMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'TestService')
.matchHeader('fiware-servicepath', '/testingPath')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerUnprovMock = nock('http://192.168.1.1:1026');

contextBrokerUnprovMock
.matchHeader('fiware-service', 'TestService')
Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/amqpBinding-test2.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ describe('AMQP Transport binding: multiple measures', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

async.series(
[
Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/attribute-alias_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ describe('Attribute alias', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://192.168.1.1:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://192.168.1.1:1026');

iotaJson.start(config, function () {
request(provisionOptions, function (error, response, body) {
Expand Down
6 changes: 0 additions & 6 deletions test/unit/ngsiv2/commandsAmqp-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ describe('AMQP Transport binding: commands', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

oldTransport = config.defaultTransport;
config.defaultTransport = 'AMQP';

Expand Down
6 changes: 0 additions & 6 deletions test/unit/ngsiv2/commandsPolling-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ describe('HTTP Transport binding: polling commands', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);

mockedClientServer = nock('http://localhost:9876')
.post('/command', 'MQTT_2@PING|data=22')
.reply(200, 'MQTT_2@PING|1234567890');
Expand Down
6 changes: 1 addition & 5 deletions test/unit/ngsiv2/configuration-api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@ describe('Configuration API support', function () {
// This mock does not check the payload since the aim of the test is not to verify
// device provisioning functionality. Appropriate verification is done in tests under
// provisioning folder of iotagent-node-lib
contextBrokerMock = nock('http://unexistentHost:1026')
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', '/gardens')
.post('/v2/entities?options=upsert')
.reply(204);
contextBrokerMock = nock('http://unexistentHost:1026');

iotagentJson.start(config, done);
});
Expand Down
Loading

0 comments on commit 6aa26c7

Please sign in to comment.