<commit_before>var Casio = require('../').Casio;
var CQL = require('../').CQL;

var Cassandra = require('cassandra-client');
var model = require('./model');
var _ = require('underscore')
var async = require('async');


//////////////////////////////
var USER, USERS = [];
var USER_OBJECTS = [
    {
        name:'<NAME>',
        first_name:'Dirty',
        last_name:'Harry',
        birthday:'12/23/1971',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:0,
        is_admin: true
    },
    {
        name:'<NAME>',
        first_name:'Mike',
        last_name:'Hunt',
        birthday:'01/01/1979',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:0,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Ben',
        last_name:'Dover',
        birthday:'11/10/1980',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:15,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Juwana',
        last_name:'Bone',
        birthday:'8/18/1984',
        gender:'F',
        state:'WI',
        email:'<EMAIL>',
        visits:421,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Oliver',
        last_name:'Clothesoff!',
        birthday:'2/13/1981',
        gender:'M',
        state:'KY',
        email:'<EMAIL>',
        visits:16001,
        is_admin: false
    }
    
]

//////////////////////////////
function createUsers(callback){
    var order = []
    _.each(USER_OBJECTS, function(props){
        order.push(function(next){
            var user = new model.User(props)
            user.create(function(err, results){
                // console.log(results)
                USERS.push(user);
                next();
            })
        })
    })
    
    async.series(order, function(err, results){
        // set USER
        USER = USERS[0];
        callback()
    })

}


//////////////////////////////

function checkClient(){
    var total=0, connected=0;
    for (var name in model){
        isConnected = model[name].prototype._clientConnected;
        if (isConnected !== undefined){
            total++;
            if(isConnected !== null) connected++;
        }
    }
    console.log('Clients connected:', connected, '/', total);
}
//////////////////////////////



exports.setUp = function(callback){
    // give the clients time to connect;
    setTimeout(function(){
        callback();
    }, 100)
}


exports.tearDown = function (callback) {
    // todo: drop the casio keyspace


    // set timeout to give 'npm test' a few seconds 
    // to do its thing
    setTimeout(function(){        
        process.exit(0);
    }, 2000);
    callback();
}

exports.test_user_something = function(test){
    // test the class method was attached
    test.equal(model.User.something(), 'this is something;')
    test.done();
}

exports.test_user_create = function(test){
    // test the class method was attached
    // test.equal(model.User.something(), 'this is something;')
    
    var order = [];
    order.push(function(next){
        createUsers(next);
    });
    order.push(function(next){
        model.User.get(USER.userId, function(err, user){
            if (err) console.log(err);
            
            // check to see if we inserted our funky property
            test.ok(user['~tilde'], 'testing');
            
            // test booleans
            test.equal(user.userId, USER.userId);<commit_msg>increase time before process dies<commit_after>var Casio = require('../').Casio;
var CQL = require('../').CQL;

var Cassandra = require('cassandra-client');
var model = require('./model');
var _ = require('underscore')
var async = require('async');


//////////////////////////////
var USER, USERS = [];
var USER_OBJECTS = [
    {
        name:'<NAME>',
        first_name:'Dirty',
        last_name:'Harry',
        birthday:'12/23/1971',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:0,
        is_admin: true
    },
    {
        name:'<NAME>',
        first_name:'Mike',
        last_name:'Hunt',
        birthday:'01/01/1979',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:0,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Ben',
        last_name:'Dover',
        birthday:'11/10/1980',
        gender:'M',
        state:'CA',
        email:'<EMAIL>',
        visits:15,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Juwana',
        last_name:'Bone',
        birthday:'8/18/1984',
        gender:'F',
        state:'WI',
        email:'<EMAIL>',
        visits:421,
        is_admin: false
    },
    {
        name:'<NAME>',
        first_name:'Oliver',
        last_name:'Clothesoff!',
        birthday:'2/13/1981',
        gender:'M',
        state:'KY',
        email:'<EMAIL>',
        visits:16001,
        is_admin: false
    }
    
]

//////////////////////////////
function createUsers(callback){
    var order = []
    _.each(USER_OBJECTS, function(props){
        order.push(function(next){
            var user = new model.User(props)
            user.create(function(err, results){
                // console.log(results)
                USERS.push(user);
                next();
            })
        })
    })
    
    async.series(order, function(err, results){
        // set USER
        USER = USERS[0];
        callback()
    })

}


//////////////////////////////

function checkClient(){
    var total=0, connected=0;
    for (var name in model){
        isConnected = model[name].prototype._clientConnected;
        if (isConnected !== undefined){
            total++;
            if(isConnected !== null) connected++;
        }
    }
    console.log('Clients connected:', connected, '/', total);
}
//////////////////////////////



exports.setUp = function(callback){
    // give the clients time to connect;
    setTimeout(function(){
        callback();
    }, 100)
}


exports.tearDown = function (callback) {
    // todo: drop the casio keyspace


    // set timeout to give 'npm test' a few seconds 
    // to do its thing
    setTimeout(function(){        
        process.exit(0);
    }, 5000);
    callback();
}

exports.test_user_something = function(test){
    // test the class method was attached
    test.equal(model.User.something(), 'this is something;')
    test.done();
}

exports.test_user_create = function(test){
    // test the class method was attached
    // test.equal(model.User.something(), 'this is something;')
    
    var order = [];
    order.push(function(next){
        createUsers(next);
    });
    order.push(function(next){
        model.User.get(USER.userId, function(err, user){
            if (err) console.log(err);
            
            // check to see if we inserted our funky property
            test.ok(user['~tilde'], 'testing');
            
            // test booleans
            test.equal(user.userId, USER.userId);
{'fraction_non_alphanumeric': 0.18117380209810036, 'fraction_numerical': 0.01729515168698611, 'mean_word_length': 1.6958349254871992, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5243176', 'n_tokens_mistral': 2159, 'n_tokens_neox': 2101, 'n_words': 415}