Skip to content

Commit

Permalink
3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tagyoureit committed Jan 28, 2017
1 parent 0a3b0a8 commit 00fbda4
Show file tree
Hide file tree
Showing 98 changed files with 12,295 additions and 517 deletions.
35 changes: 35 additions & 0 deletions specs/assets/config/configFriendlyNames.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[{
"blank": ""
}, {
"circuit1": ""
}, {
"circuit2": ""
}, {
"circuit3": ""
}, {
"circuit4": ""
}, {
"circuit5": "Waterfall Medium Low"
}, {
"circuit6": ""
}, {
"circuit7": ""
}, {
"circuit8": ""
}, {
"circuit9": ""
}, {
"circuit10": ""
}, {
"circuit11": ""
}, {
"circuit12": "Waterfall Low"
}, {
"circuit13": "Waterfall Medium"
}, {
"circuit14": "Waterfall High"
}, {
"circuit15": ""
}, {
"circuit16": ""
}]
8 changes: 4 additions & 4 deletions specs/helpers/chai.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';

var path = global.path = require('path').posix
var chai = global.chai = require('chai');
global.sinon = require('sinon')
global.sinonChai = require("sinon-chai");
var nock = global.nock = require('nock')
var rewire = global.rewire = require("rewire");
var nodejspoolcontroller = require('../../lib/app')
var nodejspoolcontroller = require(path.join(process.cwd(),'/src/lib/app'))
var Bottle = global.Bottle = require('bottlejs')
var path = global.path = require('path').posix


var chaiAsPromised = require('chai-as-promised');
chai.use(chaiAsPromised);
Expand All @@ -24,7 +24,7 @@ global.AssertionError = chai.AssertionError;
global.Assertion = chai.Assertion;
global.assert = chai.assert;

var fs = require('promised-io/fs')
var fs = global.fs = require('promised-io/fs')

fs.readFile(path.join(process.cwd(), '/specs/assets/webJsonReturns', 'circuit.json'), 'utf8')
.then(function(data) {
Expand Down
2 changes: 1 addition & 1 deletion specs/lib/comms/decodeHelper.checksum.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var myModule = rewire(path.join(process.cwd(), '/lib/comms/inbound/decode-helper.js'))
var myModule = rewire(path.join(process.cwd(), '/src/lib/comms/inbound/decode-helper.js'))

describe('decodeHelper', function() {
var testarrayGOOD = [
Expand Down
23 changes: 0 additions & 23 deletions specs/lib/comms/foobar.js

This file was deleted.

16 changes: 0 additions & 16 deletions specs/lib/comms/foobar.spec.js

This file was deleted.

185 changes: 185 additions & 0 deletions specs/lib/comms/server.api.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
//var URL = 'https://localhost:3000/';
var URL = 'http://localhost:3000/'
//var ENDPOINT = 'all'

var myModule = rewire(path.join(process.cwd(), '/src/lib/comms', 'server.js'))

function requestPoolDataWithURL(endpoint) {
//console.log('pending - request sent for ' + endpoint)
return getAllPoolData(endpoint).then(
function(response) {
// console.log('success - received data for %s request: %s', endpoint, JSON.stringify(response.body));
return response.body;
}
);
};

function getAllPoolData(endpoint) {
var options = {
method: 'GET',
uri: URL + endpoint,
resolveWithFullResponse: true,
json: true
};
return rp(options);
};


describe('#set functions', function() {

before(function() {
nock.restore()
bottle.container.server.app
})
describe('#sends pump commands', function() {
context('with a REST API', function() {

before(function() {
sandbox = sinon.sandbox.create()
});

beforeEach(function() {})

afterEach(function() {
//restore the sandbox after each function
sandbox.restore()
bottle.container.logger.warn.restore()
bottle.container.pumpControllerMiddleware.pumpCommand.restore()
})

it('sets pump 1 to program 1', function() {
var loggerStub = sinon.stub(bottle.container.logger, 'warn')


var pumpCommandStub = sinon.stub(bottle.container.pumpControllerMiddleware, 'pumpCommand')
return requestPoolDataWithURL('pumpCommand/1/1').then(function(result) {


console.log('loggerStub called with: ', loggerStub.args)
console.log('pumpCommandStub2 called with: ', pumpCommandStub.args)
console.log('result: ', result)
loggerStub.args[0][0].should.eq('Please update the URL to the new format: /pumpCommand/{run or save}/pump/1/program/1')
pumpCommandStub.args[0][0].should.eq(1)
pumpCommandStub.args[0][1].should.eq('1') //should be a sting because it could be 0-4 or on/off
result.program.should.eq('1')


})

});
/* it('saves pump 1 to program 1 (should fail)', function(done) {
requestPoolDataWithURL('pumpCommand/save/pump/1/program/1').then(function(obj) {
obj.should.eq('need to get results and put here')
//obj.text.should.eq('Please provide a speed /speed/{speed} when requesting to save the program');
done()
});
});
it('runs pump 1 to program 1 (NEW URL)', function(done) {
requestPoolDataWithURL('pumpCommand/run/pump/1/program/1').then(function(obj) {
obj.should.eq({
"text": "REST API pumpCommand variables - pump: 1, program: 1, value: null, duration: null",
"pump": "1",
"program": "1"
});
done()
});
});
it('sets pump 1 program 1 to 1000 rpm', function(done) {
requestPoolDataWithURL('pumpCommand/1/1/1000').then(function(obj) {
//console.log('myObj sets pump 1 program 1 to 1000 rpm: ', obj)
obj.should.eq({
"text": "REST API pumpCommand variables - pump: 1, program: 1, rpm: 1000, duration: null",
"pump": "1",
"program": "1",
"value": "1000",
"duration": null
})
done()
});
});
it('saves pump 1 program 1 to 1000 rpm (NEW URL)', function() {
requestPoolDataWithURL('pumpCommand/save/pump/1/program/1/rpm/1000').then(function(obj) {
obj.should.eq({
"text": "REST API pumpCommand variables - pump: 1, program: 1, rpm: 1000, duration: null",
"pump": "1",
"program": "1",
"speed": "1000"
})
done()
});
});
it('saves pump 1 and rpm 1 (should fail // no program)', function(done) {
requestPoolDataWithURL('pumpCommand/save/pump/1/rpm/1000').then(function(obj) {
console.log('bbb: ', obj)
obj.should.eq({
"text": "Please provide the program number when saving the program. /pumpCommand/save/pump/#/program/#/rpm/#"
})
done()
})
});
it('runs pump 1 at rpm 1000 (should fail // no program)', function(done) {
requestPoolDataWithURL('pumpCommand/save/pump/1/program/1').then(function(obj) {
obj.text.should.eq('Please provide a program when setting the RPM. /pumpCommand/run/pump/rpm/#');
done()
});
});
it('sets pump 1 to program 1 at 1000 rpm for 2 minutes', function(done) {
requestPoolDataWithURL('pumpCommand/1/1/1000/2').then(function(obj) {
obj.should.eq({
"text": "REST API pumpCommand variables - pump: 1, program: 1, speed: 1000, duration: 2",
"pump": "1",
"program": "1",
"speed": "1000",
"duration": "2"
})
done()
});
});
it('runs pump 1, program 1 for 2 minutes ', function(done) {
requestPoolDataWithURL('pumpCommand/pump/1/program/1/duration/2').then(function(obj) {
obj.should.eq({
"text": "REST API pumpCommand variables - pump: 1, program: 1, duration: 2",
"pump": "1",
"duration": "2"
});
done()
});
});
it('runs pump 1, program 1 for 2 minutes (NEW URL)', function(done) {
requestPoolDataWithURL('pumpCommand/run/pump/1/program/1/duration/2').then(function(obj) {
obj.should.eq('need to get results and put here');
done()
});
});
it('saves and runs pump 1 to program 1 at 1000 rpm for 2 minutes (NEW URL)', function(done) {
requestPoolDataWithURL('pumpCommand/run/pump/1/program/1/rpm/1000/duration/2').then(function(obj) {
obj.should.eq('need to get results and put here')
done()
});
});
*/
});

});
});
Loading

0 comments on commit 00fbda4

Please sign in to comment.