def test_should_upload_output_image_given_aws_queue_when_completed(self):
     #construct
     params = {
               "ratio":1e5,
               "num_iters":1,
               "length":512,
               "verbose":False
               }
     art_task = ArtTask('id'+str(random.randint(1000000, 9999999)),params)
     art_task.content_image = caffe.io.load_image('test-resource/content-image/face-1.jpg')
     art_task.style_image = caffe.io.load_image('resource/style-image/starry_night.jpg')
     art_task.output_image = caffe.io.load_image('test-resource/content-image/face-1.jpg')
     
     self._local_task_output_queue.put_nowait(art_task)
     time.sleep(30)
     
     # verify
     s3_bucket = os.environ['S3_IMAGE_BUCKET']
     output_image_url = 'http://'+s3_bucket+'.s3.amazonaws.com/' + datetime.date.today().strftime('%Y%m%d') + '/'+art_task._id+'/'+art_task._id+'-output.jpg'
     output_image = caffe.io.load_image(output_image_url)
     self.assertIsNotNone(output_image)
     logging.info('verify uploaded image pass')
 def test_should_send_completion_given_aws_queue_when_completed(self):
     #construct
     params = {
               "ratio":1e5,
               "num_iters":1,
               "length":512,
               "verbose":False
               }
     art_task = ArtTask('id12345',params)
     art_task.content_image = caffe.io.load_image('test-resource/content-image/face-1.jpg')
     art_task.style_image = caffe.io.load_image('resource/style-image/starry_night.jpg')
     art_task.output_image = caffe.io.load_image('test-resource/content-image/face-1.jpg')
     
     self._local_task_output_queue.put_nowait(art_task)
     time.sleep(30)
     
     # check 
     messages = self._aws_task_completion_queue.receive_messages()
     self.assertEqual(1, len(messages))
     completion_message = messages[0]
     completion = json.loads(completion_message.body)
     self.assertEquals('id12345',completion['_id'])
     self.assertIsNotNone(completion['outputImageUrl'])