Skip to content

Commit

Permalink
Merge pull request #33 from ibmtjbot/bugfix/jw-cameraTest
Browse files Browse the repository at this point in the history
Fixed camera test
  • Loading branch information
victordibia authored Apr 20, 2017
2 parents 5f3b473 + fe08ca2 commit da13e00
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 8 deletions.
59 changes: 59 additions & 0 deletions bootstrap/tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env

# .DS_Store files
.DS_Store
15 changes: 10 additions & 5 deletions bootstrap/tests/test.camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,21 @@ const fs = require('fs');

const TJBot = require('tjbot');

var tj = new TJBot(['camera'], {}, {});
// just need tjbot to think that it is capable of seeing, don't
// actually need real Watson credentials for this test
const dummyWatsonCredentials = {
visual_recognition: {
api_key: 'abc-def-ghi'
}
};

tj._captureImage('picture.jpg').then(function(data) {
var tj = new TJBot(['camera'], {log: {level: 'debug'}}, dummyWatsonCredentials);
tj.takePhoto('picture.jpg').then(function(data) {
if (!fs.existsSync('picture.jpg')) {
throw new Error("expected picture.jpg to have been created");
}
console.log("picture taken successfully, removing the file");
if (fs.existsSync('picture.jpg')) {
fs.unlink('picture.jpg');
}
if (fs.existsSync('picture.jpg')) {
throw new Error("expected to have deleted picture.jpg");
}
});
2 changes: 1 addition & 1 deletion bootstrap/tests/test.led.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rl = require('readline-sync');

const TJBot = require('tjbot');

var tj = new TJBot(['led'], {}, {});
var tj = new TJBot(['led'], {log: {level: 'debug'}}, {});
var colors = ['red', 'green', 'blue', 'orange', 'off'];

colors.forEach(function(color) {
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/tests/test.servo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rl = require('readline-sync');

const TJBot = require('tjbot');

var tj = new TJBot(['servo'], {}, {});
var tj = new TJBot(['servo'], {log: {level: 'debug'}}, {});

tj.armBack();
var answer = rl.question('Is TJBot\'s arm in the BACKWARD position? Y/N > ');
Expand Down
2 changes: 1 addition & 1 deletion bootstrap/tests/test.speaker.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rl = require('readline-sync');

const TJBot = require('tjbot');

var tj = new TJBot(['speaker'], {}, {});
var tj = new TJBot(['speaker'], {log: {level: 'debug'}}, {});

var sound = '/usr/share/sounds/alsa/Front_Center.wav';
tj.play(sound).then(function() {
Expand Down

0 comments on commit da13e00

Please sign in to comment.