<commit_before>var _ = require('lodash');
var should = require('should');
var sinon = require('sinon');
var setup = require('../_setup');
var Promise = require('bluebird');
var moment = require('moment');
require('should-sinon');

describe('Action formCiconia:', function () {
  var ciconiaRecord = {
    latitude: 42.1463749,
    longitude: 24.7492006,
    observationDateTime: '2016-12-20T12:15Z',
    monitoringCode: 'random_ciconia_1234',
    primarySubstrateType: {
      type: 'ciconia_substratum',
      label: {
        bg: 'ciconia_substratum',
        en: 'ciconia_substratum'
      }

    },
    electricityPole: {
      type: 'ciconia_column',
      label: {
        bg: 'Imm.',
        en: 'Imm.'
      }
    },
    typeElectricityPole: {
      type: 'ciconia_column_type',
      label: {
        bg: 'ciconia_column_type',
        en: 'ciconia_column_type'
      }
    },
    nestOnArtificialHumanMadePlatform: true,
    nestIsOnAnotherTypeOfSubstrate: 'blah blah',
    nestThisYearNotUtilizedByWhiteStorks: {
      type: 'ciconia_not_occupied',
      label: {
        bg: 'ciconia_not_occupied',
        en: 'ciconia_not_occupied'
      }
    },
    approximateDateStorksAppeared: '2015-03-10T12:15Z',
    approximateDateDisappearanceWhiteStorks: '2015-08-10T12:15Z',
    countJuvenilesInNest: 3,
    nestNotUsedForOverOneYear: 1,
    dataOnJuvenileMortalityFromElectrocutions: 1,
    dataOnJuvenilesExpelledFromParents: 1,
    diedOtherReasons: 23,
    reason: 'some reason',
    speciesNotes: 'some notes text',
    location: 'location somewhere',

    endDateTime: '10/12/2015 10:15',
    startDateTime: '09/12/2015 08:10',
    observers: 'Some test observers',
    rain: {
      type: 'main_rain',
      label: {
        bg: 'Ръми',
        en: 'Drizzle'
      }
    },
    temperature: 24.3,
    windDirection: {
      type: 'main_wind_direction',
      label: {
        bg: 'ENE',
        en: 'ENE'
      }
    },
    windSpeed: {
      type: 'main_wind_force',
      label: {
        bg: '2 - Лек бриз',
        en: '2 - Light breeze'
      }
    },
    cloudiness: {
      type: 'main_cloud_level',
      label: {
        bg: '33-66%',
        en: '33-66%'
      }
    },
    cloudsType: 'Light grey clouds',
    visibility: 5.5,
    mto: 'pretty nice weather',
    threats: [
      {
        type: 'main_threats',
        label: {
          bg: 'Култивация',
          en: 'Cultivation'
        }
      },
      {
        type: 'main_threats',
        label: {
          bg: 'Наторяване',
          en: 'Mulching'
        }
      }
    ],
    notes: 'some notes'
  };

  before(function () {
    return setup.init();
  });

  after(function () {
    return setup.finish();
  });

  describe('Guest user', function () {
    setup.describeAsGuest(function (runAction) {
      it('fails to create Ciconia record', function () {
        return runAction('formCiconia:create', ciconiaRecord).then(function (response) {
          response.error.should.be.equal('Error: Please log in to continue');
        });
      });
    });
  }); // Guest user

  setup.describeAsAuth(function (runAction) {
    describe('fails to create without', function () {
      var required = ['latitude', 'longitude', 'observationDateTime', 'monitoringCode',
        'endDateTime', 'startDateTime', 'location', 'user'];

      required.forEach(function (property) {
        it(property, function () {
          var reqCiconiaObj = _.cloneDeep(ciconiaRecord);
          delete reqCiconiaObj[property];
          return runAction('formCiconia:create', reqCiconiaObj).then(function (response) {
            response.error.should.be.equal('Error: ' + property + ' is a required parameter for this action');
          });
        });
      });

    }); // fails to create without

    describe('CREATE', function () {
      it('creates Ciconia record', function () {
        return runAction('formCiconia:create', ciconiaRecord).then(function (response) {
          should.not.exist(response.error);<commit_msg>fix ciconia tests for mandatory fields<commit_after>var _ = require('lodash');
var should = require('should');
var sinon = require('sinon');
var setup = require('../_setup');
var Promise = require('bluebird');
var moment = require('moment');
require('should-sinon');

describe('Action formCiconia:', function () {
  var ciconiaRecord = {
    latitude: 42.1463749,
    longitude: 24.7492006,
    observationDateTime: '2016-12-20T12:15Z',
    monitoringCode: 'random_ciconia_1234',
    primarySubstrateType: {
      type: 'ciconia_substratum',
      label: {
        bg: 'ciconia_substratum',
        en: 'ciconia_substratum'
      }

    },
    electricityPole: {
      type: 'ciconia_column',
      label: {
        bg: 'Imm.',
        en: 'Imm.'
      }
    },
    typeElectricityPole: {
      type: 'ciconia_column_type',
      label: {
        bg: 'ciconia_column_type',
        en: 'ciconia_column_type'
      }
    },
    nestOnArtificialHumanMadePlatform: true,
    nestIsOnAnotherTypeOfSubstrate: 'blah blah',
    nestThisYearNotUtilizedByWhiteStorks: {
      type: 'ciconia_not_occupied',
      label: {
        bg: 'ciconia_not_occupied',
        en: 'ciconia_not_occupied'
      }
    },
    approximateDateStorksAppeared: '2015-03-10T12:15Z',
    approximateDateDisappearanceWhiteStorks: '2015-08-10T12:15Z',
    countJuvenilesInNest: 3,
    nestNotUsedForOverOneYear: 1,
    dataOnJuvenileMortalityFromElectrocutions: 1,
    dataOnJuvenilesExpelledFromParents: 1,
    diedOtherReasons: 23,
    reason: 'some reason',
    speciesNotes: 'some notes text',
    location: 'location somewhere',

    endDateTime: '10/12/2015 10:15',
    startDateTime: '09/12/2015 08:10',
    observers: 'Some test observers',
    rain: {
      type: 'main_rain',
      label: {
        bg: 'Ръми',
        en: 'Drizzle'
      }
    },
    temperature: 24.3,
    windDirection: {
      type: 'main_wind_direction',
      label: {
        bg: 'ENE',
        en: 'ENE'
      }
    },
    windSpeed: {
      type: 'main_wind_force',
      label: {
        bg: '2 - Лек бриз',
        en: '2 - Light breeze'
      }
    },
    cloudiness: {
      type: 'main_cloud_level',
      label: {
        bg: '33-66%',
        en: '33-66%'
      }
    },
    cloudsType: 'Light grey clouds',
    visibility: 5.5,
    mto: 'pretty nice weather',
    threats: [
      {
        type: 'main_threats',
        label: {
          bg: 'Култивация',
          en: 'Cultivation'
        }
      },
      {
        type: 'main_threats',
        label: {
          bg: 'Наторяване',
          en: 'Mulching'
        }
      }
    ],
    notes: 'some notes'
  };

  before(function () {
    return setup.init();
  });

  after(function () {
    return setup.finish();
  });

  describe('Guest user', function () {
    setup.describeAsGuest(function (runAction) {
      it('fails to create Ciconia record', function () {
        return runAction('formCiconia:create', ciconiaRecord).then(function (response) {
          response.error.should.be.equal('Error: Please log in to continue');
        });
      });
    });
  }); // Guest user

  setup.describeAsAuth(function (runAction) {
    describe('fails to create without', function () {
      var required = ['latitude', 'longitude', 'observationDateTime', 'monitoringCode',
        'endDateTime', 'startDateTime', 'location'];

      required.forEach(function (property) {
        it(property, function () {
          var reqCiconiaObj = _.cloneDeep(ciconiaRecord);
          delete reqCiconiaObj[property];
          return runAction('formCiconia:create', reqCiconiaObj).then(function (response) {
            response.error.should.be.equal('Error: ' + property + ' is a required parameter for this action');
          });
        });
      });

    }); // fails to create without

    describe('CREATE', function () {
      it('creates Ciconia record', function () {
        return runAction('formCiconia:create', ciconiaRecord).then(function (response) {
          should.not.exist(response.error);
{'fraction_non_alphanumeric': 0.1357686074055604, 'fraction_numerical': 0.025682583219049995, 'mean_word_length': 2.4562688496337786, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5899241', 'n_tokens_mistral': 2783, 'n_tokens_neox': 2580, 'n_words': 505}