-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AN-297-Adding unit tests for Device Registry. #1343
Closed
+4,067
−654
Closed
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
7fa84e6
AN-297-Adding tests for create site util
BenjaminSsempala dd88f8e
Merge branch 'staging' into AN-297-Adding-unit-tests
BenjaminSsempala 4a4db8c
AN-297-Some SETUP works
BenjaminSsempala 4215420
AN-297-Finallising create-sites-util test
BenjaminSsempala 86c85bb
AN-297-create-device-utils
BenjaminSsempala ee31a50
AN-297-Finalising create-site-util-test
BenjaminSsempala c0d7ce2
AN-297-Create device tests
BenjaminSsempala d2abaeb
Merge branch 'staging' into AN-297-Adding-unit-tests
BenjaminSsempala aa4b2b1
AN-297-create activity tests
BenjaminSsempala 623659b
AN-297-removing brackets and small changes
BenjaminSsempala 5490593
Merge branch 'staging' into AN-297-Adding-unit-tests
BenjaminSsempala c324ad8
Merge branch 'staging' into AN-297-Adding-unit-tests
BenjaminSsempala 78e85ec
Create airQloud, and multitenancy
BenjaminSsempala cbad65b
Tests For Create-airQolud
BenjaminSsempala 4a2579e
Tests for Multitenancy
BenjaminSsempala c08b3c5
Tests for Logging functionality
BenjaminSsempala d313f75
Tests for generate Filter
BenjaminSsempala 248beef
Unit tests for date.js
BenjaminSsempala a5728dc
Unit tests for distance.js
BenjaminSsempala 9bedb7e
Photo util and sensor util unit tests
BenjaminSsempala 09edb4e
create Monitor tests
BenjaminSsempala 640483b
Testing errors.js
BenjaminSsempala 50d9974
Create-Location tests
BenjaminSsempala e383ff7
Tests for health-tips
BenjaminSsempala 0a3c509
part of create EVents
BenjaminSsempala b3897c2
create event
BenjaminSsempala f24746c
updating scripts
BenjaminSsempala 102dc88
Merge branch 'staging' into AN-297-Adding-unit-tests
BenjaminSsempala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
"use-strict"; | ||
const imageController = require("../Device"); | ||
|
||
let chai = require("chai"), | ||
expect = chai.expect; | ||
chai.should(); | ||
const chaiHttp = require("chai-http"); | ||
const should = chai.should(); | ||
const assert = chai.assert; | ||
const faker = require("faker"); | ||
const sinon = require("sinon"); | ||
const request = require("request"); | ||
chai.use(chaiHttp); | ||
const DeviceSchema = require("../Device"); | ||
const SiteModel = require("../../utils/multitenancy"); | ||
|
||
const stubValue = { | ||
_name_id: faker.datatype.uuid(), | ||
tenant: "airqo", | ||
name: faker.name.findName(), | ||
latitude: faker.address.latitude(), | ||
longitude: faker.address.longitude(), | ||
createdAt: faker.date.past(), | ||
updatedAt: faker.date.past(), | ||
approximate_distance_in_km: faker.datatype.float(), | ||
writeKey: faker.name.writeKey(), | ||
readKey: faker.name.readKey(), | ||
network:faker.company.network(), | ||
access_code:faker.datatype.int(), | ||
visibility: faker.datatype.boolean(), | ||
generation_version: faker.datatype.float(), | ||
generation_count:faker.datatype.int(), | ||
mobility: faker.datatype.boolean(), | ||
height: faker.datatype.float(), | ||
mountType:faker.datatype.mountType(), | ||
device_codes:faker.datatype.array(), | ||
status: faker.datatype.status(), | ||
ISP:faker.datatype.ISP(), | ||
phoneNumber: faker.phone.unique(), | ||
powerType:faker.random.powerType(), | ||
host_id: faker.random.unique(), | ||
site_id:faker.datatype.uuid(), | ||
device_number: faker.random.unique(), | ||
category: faker.name.category(), | ||
isActive:faker.datatype.isActive() | ||
}; | ||
|
||
describe("create a device", function() { | ||
beforeEach(function() {}); | ||
afterEach(function() {}); | ||
it("should have validation error for a duplicate compoment type name", function () { | ||
|
||
}); | ||
}); | ||
|
||
describe("read device ", function() { | ||
beforeEach(function() {}); | ||
afterEach(function() {}); | ||
it("should find the existing device ", function () { | ||
|
||
}); | ||
}); | ||
|
||
describe("deleting device ", function() { | ||
beforeEach(function() {}); | ||
afterEach(function() {}); | ||
it("should delete a device using ID", function () { | ||
|
||
}); | ||
|
||
it("should delete a device using the name", function () { | ||
|
||
}); | ||
|
||
it("should remove multiple device ", function () { | ||
|
||
}); | ||
|
||
it("should remove device using its instance", function () { | ||
|
||
}); | ||
}); | ||
BenjaminSsempala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
describe("updating a device", function() { | ||
beforeEach(function() {}); | ||
afterEach(function() {}); | ||
it("should set and saves a device using an instance", function() {}); | ||
|
||
it("should update a device using its instance", function() {}); | ||
|
||
it("should update one device using the model", function() {}); | ||
|
||
it("should update one device with ID using model", function() {}); | ||
|
||
it("should return error is the update action fails", function() {}); | ||
}); |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,112 +1,117 @@ | ||
{ | ||
"name": "device-registry", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "./bin/www", | ||
"scripts": { | ||
"start": "NODE_ENV=production node --max-old-space-size=1024 ./bin/www", | ||
"stage": "NODE_ENV=staging node --max-old-space-size=1024 ./bin/www", | ||
"dev-mac": "NODE_ENV=development nodemon --max-old-space-size=1024 ./bin/www", | ||
"prod-mac": "NODE_ENV=production nodemon --max-old-space-size=1024 ./bin/www", | ||
"stage-mac": "NODE_ENV=staging nodemon --max-old-space-size=1024 ./bin/www", | ||
"dev-pc": "SET NODE_ENV=development&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"prod-pc": "SET NODE_ENV=production&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"stage-pc": "SET NODE_ENV=staging&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"prettier": "prettier --single-quote --print-width 80 --trailing-comma all --write 'src/**/*.js'", | ||
"test": "mocha ./**/test/ut_*.js --exit" | ||
}, | ||
"_moduleAliases": { | ||
"@root": ".", | ||
"@models": "models/", | ||
"@utils": "utils", | ||
"@controllers": "controllers", | ||
"@config": "config", | ||
"@middleware": "middleware", | ||
"@scripts": "scripts", | ||
"@routes": "routes" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/bigquery": "^5.5.0", | ||
"@google-cloud/iot": "^1.5.0", | ||
"@googlemaps/google-maps-services-js": "^3.1.16", | ||
"@kafkajs/confluent-schema-registry": "^3.0.1", | ||
"@log4js-node/slack": "^1.0.0", | ||
"adm-zip": "^0.5.10", | ||
"app-module-path": "^2.2.0", | ||
"avsc": "^5.4.16", | ||
"axios": "^0.21.4", | ||
"body-parser": "^1.18.3", | ||
"clean-deep": "^3.4.0", | ||
"cloudinary": "^1.23.0", | ||
"compression": "^1.7.4", | ||
"connect-mongo": "^3.2.0", | ||
"cookie-parser": "~1.4.3", | ||
"crypto-js": "^4.1.1", | ||
"debug": "~2.6.9", | ||
"decimal-places": "0.0.2", | ||
"dot-object": "^2.1.4", | ||
"dotenv": "^8.2.0", | ||
"express": "^4.17.1", | ||
"express-cluster": "0.0.5", | ||
"express-session": "^1.17.1", | ||
"express-validation": "^1.0.3", | ||
"express-validator": "^6.12.0", | ||
"generate-password": "^1.7.0", | ||
"geolib": "^3.3.3", | ||
"google-libphonenumber": "^3.2.22", | ||
"helmet": "^3.21.1", | ||
"http-status": "^1.4.0", | ||
"install": "^0.13.0", | ||
"is-empty": "^1.2.0", | ||
"jade": "~1.11.0", | ||
"joi": "^14.3.1", | ||
"json2csv": "^5.0.7", | ||
"jsonrepair": "^3.0.2", | ||
"jsonwebtoken": "^8.5.1", | ||
"kafka-node": "^5.0.0", | ||
"kafkajs": "^1.16.0", | ||
"log4js": "^6.3.0", | ||
"module-alias": "^2.2.2", | ||
"moesif-nodejs": "^3.2.2", | ||
"mongoose": "^5.13.5", | ||
"mongoose-unique-validator": "^2.0.3", | ||
"morgan": "^1.9.1", | ||
"mqtt": "^3.0.0", | ||
"multer": "^1.4.2", | ||
"ngeohash": "^0.6.3", | ||
"node-fetch": "^2.6.1", | ||
"node-json-transform": "^1.1.2", | ||
"nodemon": "^1.19.4", | ||
"npm": "^7.20.5", | ||
"numeral": "^2.0.6", | ||
"passport": "^0.4.0", | ||
"passport-jwt": "^4.0.0", | ||
"point-in-polygon": "^1.1.0", | ||
"qrcode": "^1.4.4", | ||
"qs": "^6.9.4", | ||
"redis": "^3.1.2", | ||
"request": "^2.88.2", | ||
"retry-request": "^4.1.1", | ||
"serve-favicon": "~2.4.5", | ||
"shapefile": "^0.6.6", | ||
"underscore": "^1.13.1", | ||
"unique-names-generator": "^4.3.0", | ||
"uuid": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"acorn": "^6.4.2", | ||
"chai": "^4.3.3", | ||
"chai-http": "^4.3.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"faker": "^5.5.3", | ||
"gulp": "^4.0.2", | ||
"gulp-mocha": "^8.0.0", | ||
"gulp-util": "^3.0.8", | ||
"mocha": "^8.1.3", | ||
"prettier": "1.18.2", | ||
"sinon": "^9.2.4", | ||
"supertest": "^4.0.2" | ||
} | ||
} | ||
"name": "device-registry", | ||
"version": "0.0.0", | ||
"private": true, | ||
"main": "./bin/www", | ||
"scripts": { | ||
"start": "NODE_ENV=production node --max-old-space-size=1024 ./bin/www", | ||
"stage": "NODE_ENV=staging node --max-old-space-size=1024 ./bin/www", | ||
"dev-mac": "NODE_ENV=development nodemon --max-old-space-size=1024 ./bin/www", | ||
"prod-mac": "NODE_ENV=production nodemon --max-old-space-size=1024 ./bin/www", | ||
"stage-mac": "NODE_ENV=staging nodemon --max-old-space-size=1024 ./bin/www", | ||
"dev-pc": "SET NODE_ENV=development&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"prod-pc": "SET NODE_ENV=production&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"stage-pc": "SET NODE_ENV=staging&&nodemon --max-old-space-size=1024 ./bin/www", | ||
"prettier": "prettier --single-quote --print-width 80 --trailing-comma all --write 'src/**/*.js'", | ||
"test": "mocha ./**/test/ut_*.js --exit", | ||
"test-models": "mocha ./models/test/ut_site.js --exit", | ||
"test-controllers": "mocha ./controllers/test/ut_create-site.js --exit", | ||
"test-utils": "mocha ./utils/test/ut_$FILE --exit", | ||
"test-utils-all": "mocha ./utils/test/ut_*.js --exit", | ||
"test-utils-sep": "node ./utils/test/generate-tests.js | xargs -0 -I {} sh -c {}" | ||
}, | ||
"_moduleAliases": { | ||
"@root": ".", | ||
"@models": "models/", | ||
"@utils": "utils", | ||
"@controllers": "controllers", | ||
"@config": "config", | ||
"@middleware": "middleware", | ||
"@scripts": "scripts", | ||
"@routes": "routes" | ||
}, | ||
"dependencies": { | ||
"@google-cloud/bigquery": "^5.5.0", | ||
"@google-cloud/iot": "^1.5.0", | ||
"@googlemaps/google-maps-services-js": "^3.1.16", | ||
"@kafkajs/confluent-schema-registry": "^3.0.1", | ||
"@log4js-node/slack": "^1.0.0", | ||
"adm-zip": "^0.5.10", | ||
"app-module-path": "^2.2.0", | ||
"avsc": "^5.4.16", | ||
"axios": "^0.21.4", | ||
"body-parser": "^1.18.3", | ||
"clean-deep": "^3.4.0", | ||
"cloudinary": "^1.23.0", | ||
"compression": "^1.7.4", | ||
"connect-mongo": "^3.2.0", | ||
"cookie-parser": "~1.4.3", | ||
"crypto-js": "^4.1.1", | ||
"debug": "~2.6.9", | ||
"decimal-places": "0.0.2", | ||
"dot-object": "^2.1.4", | ||
"dotenv": "^8.2.0", | ||
"express": "^4.17.1", | ||
"express-cluster": "0.0.5", | ||
"express-session": "^1.17.1", | ||
"express-validation": "^1.0.3", | ||
"express-validator": "^6.12.0", | ||
"generate-password": "^1.7.0", | ||
"geolib": "^3.3.3", | ||
"google-libphonenumber": "^3.2.22", | ||
"helmet": "^3.21.1", | ||
"http-status": "^1.4.0", | ||
"install": "^0.13.0", | ||
"is-empty": "^1.2.0", | ||
"jade": "~1.11.0", | ||
"joi": "^14.3.1", | ||
"json2csv": "^5.0.7", | ||
"jsonrepair": "^3.0.2", | ||
"jsonwebtoken": "^8.5.1", | ||
"kafka-node": "^5.0.0", | ||
"kafkajs": "^1.16.0", | ||
"log4js": "^6.3.0", | ||
"module-alias": "^2.2.2", | ||
"moesif-nodejs": "^3.2.2", | ||
"mongoose": "^5.13.5", | ||
"mongoose-unique-validator": "^2.0.3", | ||
"morgan": "^1.9.1", | ||
"mqtt": "^3.0.0", | ||
"multer": "^1.4.2", | ||
"ngeohash": "^0.6.3", | ||
"node-fetch": "^2.6.1", | ||
"node-json-transform": "^1.1.2", | ||
"nodemon": "^1.19.4", | ||
"npm": "^7.20.5", | ||
"numeral": "^2.0.6", | ||
"passport": "^0.4.0", | ||
"passport-jwt": "^4.0.0", | ||
"point-in-polygon": "^1.1.0", | ||
"qrcode": "^1.4.4", | ||
"qs": "^6.9.4", | ||
"redis": "^3.1.2", | ||
"request": "^2.88.2", | ||
"retry-request": "^4.1.1", | ||
"serve-favicon": "~2.4.5", | ||
"shapefile": "^0.6.6", | ||
"underscore": "^1.13.1", | ||
"unique-names-generator": "^4.3.0", | ||
"uuid": "^3.3.3" | ||
}, | ||
"devDependencies": { | ||
"acorn": "^6.4.2", | ||
"chai": "^4.3.3", | ||
"chai-http": "^4.3.0", | ||
"eslint": "^7.18.0", | ||
"eslint-config-prettier": "^6.4.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"faker": "^5.5.3", | ||
"gulp": "^4.0.2", | ||
"gulp-mocha": "^8.0.0", | ||
"gulp-util": "^3.0.8", | ||
"mocha": "^8.1.3", | ||
"prettier": "1.18.2", | ||
"sinon": "^9.2.4", | ||
"supertest": "^4.0.2" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was the motivation for adding the "alias" module to this Models file? Does it help out in the testing process? @BenjaminSsempala
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Baalmart yes, I discovered it was required but I guess because I shifted focus to first finish utils, I'll look more into this as I go into models