Skip to content

Commit

Permalink
add test for goobi
Browse files Browse the repository at this point in the history
  • Loading branch information
peetucket committed Nov 2, 2016
1 parent c9c756f commit 4e7b13b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions config/environments/local.rb
Expand Up @@ -46,9 +46,9 @@
url 'https://goobi-api-url'
dpg_workflow_name 'goobiWF' # the dpg workflow name to put into the XML
default_goobi_workflow_name 'Sample_workflow' # the default goobi workflow name to use if none found in the object
max_tries 5 # the number of attempts to retry service calls before failing
max_sleep_seconds 120 # max sleep seconds between tries
base_sleep_seconds 10 # base sleep seconds between tries
max_tries 3 # the number of attempts to retry service calls before failing
max_sleep_seconds 20 # max sleep seconds between tries
base_sleep_seconds 2 # base sleep seconds between tries
end
end

Expand Down
1 change: 0 additions & 1 deletion spec/dor_services_app_spec.rb
Expand Up @@ -274,7 +274,6 @@ def app
before(:each) { login }

it 'notifies goobi of a new registration by making a web service call' do
Dor::Config.goobi.max_tries = 1
FakeWeb.register_uri(:post, Dor::Config.goobi.url, body: '', content_type: 'text/xml')
fake_response = "<stanfordCreationRequest><objectId>#{item.pid}</objectId></stanfordCreationRequest>"
allow_any_instance_of(Dor::Goobi).to receive(:xml_request).and_return(fake_response)
Expand Down
10 changes: 9 additions & 1 deletion spec/goobi_spec.rb
Expand Up @@ -5,6 +5,8 @@
let(:item) { Dor::Item.new(pid: pid) }

before(:each) do
# all of the methods we are stubbing out below are tested elsewhere,
# this just lets us test the methods in goobi.rb without doing a lot of setup
allow(Dor::Item).to receive(:find).and_return(item)
allow(item).to receive(:source_id).and_return('some_source_id')
allow(item).to receive(:label).and_return('Object Title')
Expand All @@ -18,6 +20,7 @@
allow(@goobi).to receive(:collection_id).and_return('druid:oo000oo0001')
allow(@goobi).to receive(:collection_name).and_return('collection name')
end

it 'should create the correct xml request' do
expect(@goobi.xml_request).to be_equivalent_to <<-END
<stanfordCreationRequest>
Expand All @@ -36,6 +39,11 @@
</stanfordCreationRequest>
END
end
xit 'should make a call to the goobi server with the appropriate xml params' do

it 'should make a call to the goobi server with the appropriate xml params' do
FakeWeb.register_uri(:post, Dor::Config.goobi.url, body: '<somexml/>', content_type: 'text/xml')
expect(@goobi).to receive(:xml_request)
response = @goobi.register
expect(response).to eq(200)
end
end

0 comments on commit 4e7b13b

Please sign in to comment.