Skip to content

Commit

Permalink
Merge pull request #1411 from telefonicaid/task/do_not_create_initial…
Browse files Browse the repository at this point in the history
…_entity

update tests
  • Loading branch information
fgalan authored Aug 10, 2023
2 parents 9383b76 + 01955d4 commit 4d7c824
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
25 changes: 16 additions & 9 deletions test/unit/ngsiv2/provisioning/device-update-registration_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,6 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
.post('/v2/registrations')
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

// 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
contextBrokerMock
.matchHeader('fiware-service', 'smartgondor')
.matchHeader('fiware-servicepath', 'gardens')
.post('/v2/entities?options=upsert')
.reply(204);

iotAgentLib.activate(iotAgentConfig, function (error) {
iotAgentLib.register(device1, function (error) {
done();
Expand Down Expand Up @@ -205,6 +196,14 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
});

it('should register as ContextProvider of its lazy attributes', function (done) {
iotAgentLib.updateRegister(deviceUpdated, false, function (error) {
should.not.exist(error);
contextBrokerMock.done();
done();
});
});

it('should store the new values in the registry', function (done) {
iotAgentLib.updateRegister(deviceUpdated, false, function (error, data) {
iotAgentLib.getDevice(deviceUpdated.id, 'smartgondor', 'gardens', function (error, deviceResult) {
Expand Down Expand Up @@ -253,6 +252,14 @@ describe('NGSI-v2 - IoT Agent Device Update Registration', function () {
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });
});

it('should register as ContextProvider of its commands and create the additional attributes', function (done) {
iotAgentLib.updateRegister(deviceCommandUpdated, false, function (error) {
should.not.exist(error);
contextBrokerMock.done();
done();
});
});

it('should store the new values in the registry', function (done) {
iotAgentLib.updateRegister(deviceCommandUpdated, false, function (error, data) {
iotAgentLib.getDevice(
Expand Down
18 changes: 12 additions & 6 deletions test/unit/plugins/capture-provision-inPlugins_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ describe('NGSI-v2 - Data Mapping Plugins: device provision', function () {
)
.reply(201, null, { Location: '/v2/registrations/6319a7f5254b05844116584d' });

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

iotAgentLib.activate(iotAgentConfig, function (error) {
iotAgentLib.clearAll(done);
});
Expand Down Expand Up @@ -124,6 +118,18 @@ describe('NGSI-v2 - Data Mapping Plugins: device provision', function () {
});
});

it('should continue with the registration process', function (done) {
function testMiddleware(device, callback) {
callback(null, device);
}

iotAgentLib.addDeviceProvisionMiddleware(testMiddleware);

request(options, function (error, response, body) {
contextBrokerMock.done();
done();
});
});

it('should execute the device provisioning handlers', function (done) {
let executed = false;
Expand Down

0 comments on commit 4d7c824

Please sign in to comment.