<commit_before>/* eslint-env mocha */

const path = require('path');
const fs = require('fs');
const {promisify} = require('util');

const extract = require('extract-zip');
const parse = require('csv-parse');
const mongoose = require('mongoose');
const should = require('should');

const extractAsync = promisify(extract);

const config = require('../config.json');
const gtfs = require('../..');
const models = require('../../models/models');

const agenciesFixturesUrl = [{
  agency_key: 'caltrain',
  url: 'http://transitfeeds.com/p/caltrain/122/latest/download'
}];

const agenciesFixturesLocal = [{
  agency_key: 'caltrain',
  path: path.join(__dirname, '../fixture/caltrain_20160406.zip')
}];

describe('lib/import.js', function () {
  before(async () => {
    mongoose.set('useCreateIndex', true);
    await mongoose.connect(config.mongoUrl, {useNewUrlParser: true});
  });

  after(async () => {
    await mongoose.connection.db.dropDatabase();
    await mongoose.connection.close();
  });

  this.timeout(10000);
  describe('Download and import from different GTFS sources', () => {
    it('should be able to download and import from HTTP', async () => {
      await mongoose.connection.db.dropDatabase();
      config.agencies = agenciesFixturesUrl;
      await gtfs.import(config);<commit_msg>Specify specific version of caltrain GTFS in mocha download test<commit_after>/* eslint-env mocha */

const path = require('path');
const fs = require('fs');
const {promisify} = require('util');

const extract = require('extract-zip');
const parse = require('csv-parse');
const mongoose = require('mongoose');
const should = require('should');

const extractAsync = promisify(extract);

const config = require('../config.json');
const gtfs = require('../..');
const models = require('../../models/models');

const agenciesFixturesUrl = [{
  agency_key: 'caltrain',
  url: 'http://transitfeeds.com/p/caltrain/122/20160406/download'
}];

const agenciesFixturesLocal = [{
  agency_key: 'caltrain',
  path: path.join(__dirname, '../fixture/caltrain_20160406.zip')
}];

describe('lib/import.js', function () {
  before(async () => {
    mongoose.set('useCreateIndex', true);
    await mongoose.connect(config.mongoUrl, {useNewUrlParser: true});
  });

  after(async () => {
    await mongoose.connection.db.dropDatabase();
    await mongoose.connection.close();
  });

  this.timeout(10000);
  describe('Download and import from different GTFS sources', () => {
    it('should be able to download and import from HTTP', async () => {
      await mongoose.connection.db.dropDatabase();
      config.agencies = agenciesFixturesUrl;
      await gtfs.import(config);
{'fraction_non_alphanumeric': 0.16910935738444194, 'fraction_numerical': 0.01503194287861706, 'mean_word_length': 4.454918032786885, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5493323', 'n_tokens_mistral': 835, 'n_tokens_neox': 825, 'n_words': 182}