 
   # Mock S3 API calls
   if process.env.INTEGRATION_TEST isnt 'true'
-    listObjects = client.s3.listObjects
-    client.s3.listObjects = (path, cb) ->
+    listObjects = upload.s3.listObjects
+    upload.s3.listObjects = (path, cb) ->
       process.nextTick -> cb null, Contents: []
 
-    putObject = client.s3.putObject
-    client.s3.putObject = (opts, cb) ->
+    putObject = upload.s3.putObject
+    upload.s3.putObject = (opts, cb) ->
       process.nextTick -> cb null, ETag: hash('md5').update(rand(32)).digest('hex')
 
 # Clean up S3 objects

        dest = 'images_test/Wm/PH/f3/I0'
        opts = {}

        image = new Upload.Image src, dest, opts, client

      describe 'constructor', ->
        it 'should set default values', ->

hash = require('crypto').createHash
rand = require('crypto').pseudoRandomBytes

upload = listObjects = putObject = null
cleanup = []

beforeEach ->
  upload = new Upload 'turadmin',
    awsBucketPath: 'images_test/'
    awsBucketUrl: 'https://s3-eu-west-1.amazonaws.com/turadmin/'
    awsBucketAcl: 'public-read'
