Example #1
0
var fwk = require('fwk');
var cfg = fwk.populateConfig(require('../../config.js').config);
var instagram = require('../../lib/instagram.js').instagram();

instagram.use({
  access_token: cfg['INSTAGRAM_ACCESS_TOKEN']
});

/**
 * Some test about media features
 */
var medias = (function(spec, my) {
  var _super = {};
  my = my || {};

  // public
  var todo;

  // private

  var that = require('../test_base.js').test_base({ name: 'medias' });

  todo = function() {
    var tests = {
      'media': function(cb_) {
        var retry = 0;
        instagram.media('314584059748370098_2104944', function(err, result, limit) {
          var res = {
            ok: true,
            description: 'Retrieves a media'
          };
Example #2
0
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var util = require('util');
var fwk = require('fwk');
var http = require('http');


exports.CONFIG = fwk.populateConfig(require("../config.js").config);
 

/**
 * DaTtSs Client Library
 *
 * The Client Library requires the the auth key and if required the server and port.
 * These information can be passed directly at construction or by configuration either
 * on the command line (--XX=yyy) or using environment variables:
 *   DATTSS_CLIENT_AUTH: the auth key
 *   DATTSS_SERVER_HOST: the DaTtSs server host to use
 *   DATTSS_SERVER_PORT: the DaTtSs server port to use
 *   DATTSS_PERCENTILE : the percentile value (0.1 default)
 *
 * @extends {}
 *
Example #3
0
var test_base = function(spec, my) {
  var _super = {};
  my = my || {};

  my.name = spec.name || 'test_name';
  my.fail = 0;

  my.cfg = fwk.populateConfig(require('../config.js').config);

  // public
  var launch;
  var todo;

  var retry;
  var ok;
  var fail;

  // private

  var that = {};

  /**
   * Format message and print it in success context
   * @param name string the name of current test
   */
  ok = function(name) {
    console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': ' + name + ' ==> ' + 'OK !'.green);
  };

  /**
   * Format message and print it in failure context
   * @param name string the name of current test
   */
  fail = function(name) {
    my.fail++;
    console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': ' + name + ' ==> ' + 'FAILED !'.red);
  };
  
  /**
   * Format message and print it in retry context
   * @param name string the name of current test
   */
  retry = function(name, nr) {
    console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': ' + name + ' ==> ' + 'Retrying...'.yellow + ' [' + nr + ']');
  }

  /**
   * Launch the tests
   */
  launch = function() {
    console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': Starting...'); 
    fwk.async.parallel(that.todo(), function(err, results) {
      if(err) {
        return console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': ' + err.message);
      }
      else {
        for(var i in results) {
          if(results.hasOwnProperty(i)) {
            if(results[i].ok) {
              ok(results[i].description);
            }
            else {
              fail(results[i].description);
            }
          }
        }

        if(my.fail === 0) {
          console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': Done. ' + '(OK)'.green);
        }
        else {
          console.log('['.cyan + my.name.toUpperCase().cyan + ']'.cyan + ': Done. ' + '(FAIL)'.red);
        }
      }
    });
  };

  /**
   * Build and return tests according to the following pattern:
   * @return {
   *     'test1': function(cb_) {},
   *     'test2': function(cb_) {}
   *    }
   */
  todo = function() {
    throw new Error('`todo` must be implemented');

    return  {
      'test1': function(cb_) {
        var res = {
          ok: true,
          description: 'test a cool feature'
        };
        
        // testing stuffs ...
        if(bad_thing_happens) {
          res.ok = false;
        }

        return cb_(null, res);
      }
    };
  };

  fwk.method(that, 'launch', launch, _super);
  fwk.method(that, 'todo', todo, _super);

  fwk.method(that, 'ok', ok, _super);
  fwk.method(that, 'fail', fail, _super);
  fwk.method(that, 'retry', retry, _super);
  
  return that;
};
Example #4
0
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.

var fwk = require('fwk');
var assert = require('assert');

// cfg
var cfg = fwk.populateConfig(require("./config.js").config);

var ddb = require('../lib/ddb').ddb({accessKeyId: cfg['DYNAMODB_ACCESSKEYID'], 
                                     secretAccessKey: cfg['DYNAMODB_SECRETACCESSKEY']});


var toPut = {}
toPut[cfg['DYNAMODB_TEST_TABLE1']] = [{sha: 'blabla', status: 'on'},
                                      {sha: 'bloblo', status: 'off'},
                                      {sha: 'another', status: 'pending'}]; 

var toDelete = {};
toDelete[cfg['DYNAMODB_TEST_TABLE1']] = ['blabla', 'bloblo'];

var toGet = {};
toGet[cfg['DYNAMODB_TEST_TABLE1']] = { keys: ['another', 'blabla', 'bloblo']};