 sinon = require("sinon")
 runAsync = require("../../helpers/run-async")
 {Bucket} = require("../../../oxalis/model/binary/bucket")
+
+mockRequire.stopAll()
 
 MultipartData = require("../../../libs/multipart_data")
 # FileReader is not available in node context

          expect(buckets[1].getData()).toEqual(bucketData2)
          done()
      ])


  describe "Successful pulling", ->

    buckets = null
    bucketData1 = (i % 256 for i in [0...(32 * 32 * 32)])
    bucketData2 = ((2 * i) % 256 for i in [0...(32 * 32 * 32)])

    beforeEach ->

      buckets = [new Bucket(8, [0, 0, 0, 0], null), new Bucket(8, [1, 1, 1, 1], null)]

      for bucket in buckets
        pullQueue.add({bucket: bucket.zoomedAddress, priority : 0})
        cube.getBucketByZoomedAddress.withArgs(bucket.zoomedAddress).returns(bucket)

      responseBuffer = bucketData1.concat(bucketData2)
      RequestMock.sendArraybufferReceiveArraybuffer.reset()
      RequestMock.sendArraybufferReceiveArraybuffer.returns(Promise.resolve(responseBuffer))


