 SandboxedModule = require('sandboxed-module')
 ObjectId = require("mongojs").ObjectId
 Errors = require "../../../app/js/Errors"
+crypto = require("crypto")
 
 describe "DocArchiveManager", ->
 

				done()

		it "should return the error", (done)->
			@request.get = sinon.stub().callsArgWith(1, @error, {}, {})
			@requires["request"] = @request
			@DocArchiveManager = SandboxedModule.require modulePath, requires: @requires

			@DocArchiveManager.unarchiveDoc @project_id, @docs[0], (err)=>
				err.should.equal @error
				done()

	describe "archiveAllDocs", ->

				opts.uri.should.equal "https://#{@settings.filestore.stores.user_files}.s3.amazonaws.com/#{@project_id}/#{@docs[0]._id}"
				done()

		it "should return no md5 error", (done)->
			@md5 = crypto.createHash("md5").update(JSON.stringify(@docs[0].lines)).digest("hex")
			@request.put = sinon.stub().callsArgWith(1,  null, {statusCode:200,headers:{etag:@md5}})
			@requires["request"] = @request
			@DocArchiveManager = SandboxedModule.require modulePath, requires: @requires

			@DocArchiveManager.archiveDoc @project_id, @docs[0], (err)=>
				should.not.exist err
				done()

		it "should return the error", (done)->
			@request.put = sinon.stub().callsArgWith(1, @stubbedError, {statusCode:400,headers:{etag:""}})
			@requires["request"] = @request
			@DocArchiveManager = SandboxedModule.require modulePath, requires: @requires

			@DocArchiveManager.archiveDoc @project_id, @docs[0], (err)=>
				should.exist err
				done()

	describe "unarchiveDoc", ->
