<commit_before>//dependencies
var utils = require('./utils');
var request = require('supertest');
var express = require('express');
var config = require('../config/config');
var mongoose = require('mongoose');
var ImageModel = require('../app/models/imageMetaData.js');
var should = require('should');
var _ = require('underscore');


// express server
var app = require('../app.js');
var hashKey;

describe('#Upload', function() {
  describe('POST', function(){
      it('should have a response with status 200 on /image request', function(done){
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .expect(200)
        .end(function(error, response) {
          if (error) {
            return done(error);
          }
      
          done();
        });
      });

      it('should assign a uuid key to an uploaded image', function(done) {
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .end(function(error, response) {
          if (error) {
            return done(error);
          }
          response.text = JSON.parse(response.text);
          
          //use for later request
          hashKey = response.text.imgId;

          response.text.should.be.a('object').and.have.property('imgId');
          done();
        });
      });

      it('should store the uuid into a local db', function(done) {
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .end(function(error, response) {
          if (error) {
            return done(error);
          }

          ImageModel.find({}, function(error, models) {
            _.each(models, function(model) {
              model.should.have.property('key', hashKey);
            });

            done();
          });
        });
      });

    });
});<commit_msg>add and pass spec that test for getting image out of an s3 bucket<commit_after>//dependencies
var utils = require('./utils');
var request = require('supertest');
var express = require('express');
var config = require('../config/config');
var mongoose = require('mongoose');
var ImageModel = require('../app/models/imageMetaData.js');
var should = require('should');
var _ = require('underscore');


// express server
var app = require('../app.js');
var hashKey;

describe('#Upload', function() {
  describe('POST', function(){
      it('should respond with status 200 and a JSON object', function(done){
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .expect(200)
        .end(function(error, response) {
          if (error) {
            return done(error);
          }
          
          response.body.should.be.a('object');
          done();
        });
      });

      it('should assign a uuid key to an uploaded image', function(done) {
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .end(function(error, response) {
          if (error) {
            return done(error);
          }
          response.text = JSON.parse(response.text);
          
          hashKey = response.text.imgId;
          
          response.text.should.have.property('imgId');
          done();
        });
      });

      it('should store the uuid into a local db', function(done) {
        request(app)
        .post('/upload?imgUrl=http://maxcdn.thedesigninspiration.com/wp-content/uploads/2009/09/cute-animals/baby01.jpg')
        .end(function(error, response) {
          if (error) {
            return done(error);
          }

          ImageModel.find({}, function(error, models) {
            _.each(models, function(model) {
              model.should.have.property('key', hashKey);
            });

            done();
          });
        });

        it('should store the uploaded image in S3 bucket', function(done) {
          request(app)
          .get('https://testbucket1989.s3.amazonaws.com/' +  hashKey)
          .expect(200)
          .end(function(error, response) {
            if (error) {
              return done(error);
            }

            done();
          });
        });
      });

    });
});
{'fraction_non_alphanumeric': 0.15439856373429084, 'fraction_numerical': 0.01570915619389587, 'mean_word_length': 2.088704088704089, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '5583114', 'n_tokens_mistral': 1351, 'n_tokens_neox': 1270, 'n_words': 247}