<commit_before>var assert = require('assert');
var restify = require('restify');
var Sequelize = require("sequelize");

var models = require('../lib/models');

var client = restify.createJsonClient({
  url: 'http://localhost:8080'
});

describe('Posts user association:', function() {

  it('should log in', function(done) {
    client.post('/sessions/', {username: 'admin', password: '<PASSWORD>'}, function(err, req, res) {
      assert.equal(res.statusCode, 201);
      client.headers.cookie = res.headers['set-cookie'];
      done();
    });
  });

  it('should associate a user with a post', function(done) {
    client.get('/users/admin', function(err, req, res, user) {
       assert.equal(res.statusCode, 200);
      client.post('/posts/0/user', user, function(err, req, res) {
        assert.equal(res.statusCode, 201);
        done();
      });
    });
  });

  it('should get the associated user of a post', function(done) {
    client.get('/posts/0/user', function(err, req, res, json) {
      assert.equal(res.statusCode, 200);
      assert.equal(json.username, 'admin');
      assert.notEqual(json, null);
      done();
    });
  });

});

describe('User posts association:', function() {

  it('should associate posts with a user', function(done) {
    client.get('/posts/?limit=5', function(err, req, res, posts) {
      client.post('/users/admin/posts', posts, function(err, req, res) {
        assert.equal(res.statusCode, 201);
        done();
      });
    });
  });

  it('should get the associated posts of a user', function(done) {
    client.get('/users/admin/posts', function(err, req, res, json) {
      assert.equal(res.statusCode, 200);
      assert.equal(json.length, 5);
      done();
    });<commit_msg>Fixed tests<commit_after>var assert = require('assert');
var restify = require('restify');
var Sequelize = require("sequelize");

var models = require('../lib/models');

var client = restify.createJsonClient({
  url: 'http://localhost:8080'
});

describe('Posts user association:', function() {

  it('should log in', function(done) {
    client.post('/sessions/', {username: 'admin', password: '<PASSWORD>'}, function(err, req, res) {
      assert.equal(res.statusCode, 201);
      client.headers.cookie = res.headers['set-cookie'];
      done();
    });
  });

  it('should associate a user with a post', function(done) {
    client.get('/users/admin', function(err, req, res, user) {
       assert.equal(res.statusCode, 200);
      client.post('/posts/0/user', user, function(err, req, res) {
        assert.equal(res.statusCode, 201);
        done();
      });
    });
  });

  it('should get the associated user of a post', function(done) {
    client.get('/posts/0/user', function(err, req, res, json) {
      assert.equal(res.statusCode, 200);
      assert.equal(json.username, 'admin');
      assert.notEqual(json, null);
      done();
    });
  });

});

describe('User posts association:', function() {

  it('should associate posts with a user', function(done) {
    client.get('/posts/?limit=5', function(err, req, res, posts) {
      client.post('/users/admin/posts', posts, function(err, req, res) {
        assert.equal(res.statusCode, 201);
        done();
      });
    });
  });

  it('should get the associated posts of a user', function(done) {
    client.get('/users/admin/posts', function(err, req, res, json) {
      assert.equal(res.statusCode, 200);
      assert.equal(json.length, 50);
      done();
    });
{'fraction_non_alphanumeric': 0.1845976348428036, 'fraction_numerical': 0.015286991635419672, 'mean_word_length': 3.292079207920792, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2722354', 'n_tokens_mistral': 1133, 'n_tokens_neox': 1069, 'n_words': 251}