From 80805703a5932454d3ac967b805937cf136c19cc Mon Sep 17 00:00:00 2001 From: Victory Date: Sun, 17 Jan 2016 14:35:18 -0500 Subject: [PATCH 1/2] fix quandl default version test fixes #4 --- test/quandl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/quandl.js b/test/quandl.js index 811c96d..68fcbe8 100644 --- a/test/quandl.js +++ b/test/quandl.js @@ -24,7 +24,7 @@ describe("quandl", function(){ }); it("default config parameters are set correctly", function(){ - assert.equal(quandl.api_version, "v1"); + assert.equal(quandl.api_version, "v3"); assert.equal(quandl.auth_token, undefined); }); From 6d4430d81bca3032a90c565ef25efa1ef511e291 Mon Sep 17 00:00:00 2001 From: Victory Date: Sun, 17 Jan 2016 15:18:45 -0500 Subject: [PATCH 2/2] add support for last uri call, and show failing test for CBOE/VXEEM --- lib/api.js | 12 ++++++++---- quandl.js | 1 + test/quandl.js | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/lib/api.js b/lib/api.js index 5d167ab..190d10e 100644 --- a/lib/api.js +++ b/lib/api.js @@ -16,8 +16,9 @@ module.exports = { var qs = options; qs.auth_token = this.auth_token; + this.last_uri_called = ["api", this.api_version, "datasets", code.source, code.table].join("/"); var config = { - uri: ["api", this.api_version, "datasets", code.source, code.table].join("/"), + uri: this.last_uri_called, format: format, qs: qs, proxy: this.proxy @@ -57,8 +58,9 @@ module.exports = { return combined_code; }).join(","); + this.last_uri_called = ["api", this.api_version, "multisets"].join("/"); var config = { - uri: ["api", this.api_version, "multisets"].join("/"), + uri: this.last_uri_called, format: format, qs: qs, proxy: this.proxy @@ -79,8 +81,9 @@ module.exports = { var qs = options; qs.auth_token = this.auth_token; + this.last_uri_called = ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/"); var config = { - uri: ["api", this.api_version, "current_user", "collections", "datasets", "favourites"].join("/"), + uri: this.last_uri_called, format: format, qs: qs, proxy: this.proxy @@ -102,8 +105,9 @@ module.exports = { qs.auth_token = this.auth_token; qs.query = terms.replace(" ", "+"); + this.last_uri_called = ["api", this.api_version, "datasets"].join("/"); var config = { - uri: ["api", this.api_version, "datasets"].join("/"), + uri: this.last_uri_called, format: format, qs: qs, proxy: this.proxy diff --git a/quandl.js b/quandl.js index c315f75..f6f1d43 100644 --- a/quandl.js +++ b/quandl.js @@ -3,6 +3,7 @@ var api = require([__dirname, "lib", "api"].join("/")); function Quandl(config){ this.configure(config || {}); + this.last_uri_called = ""; // contains the string value of the last uri called for debugging and testing, empty if no calls made } Quandl.prototype.configure = function(config){ diff --git a/test/quandl.js b/test/quandl.js index 68fcbe8..4aa3023 100644 --- a/test/quandl.js +++ b/test/quandl.js @@ -41,4 +41,27 @@ describe("quandl", function(){ }); }); + + + describe("contains last_uri_call", function(){ + it("contains an empty string value", function() { + assert.equal(quandl.last_uri_called, ""); + }); + + it("has correct api call for v3", function() { + quandl.configure({ + api_version: 3, + auth_token: "dsahFHUiewjjd" + }); + + quandl.dataset( + {source: 'CBOE/VXEEM', format: 'json'}, + function(){}); + + assert.equal( + quandl.last_uri_called, + "api/v1/datasets/CBOE/VXEEM.json"); + }); + }); + });