dor-workflow-service 1.7.2 → 1.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.travis.yml +1 -2
- data/Gemfile +0 -5
- data/dor-workflow-service.gemspec +3 -3
- data/lib/dor/services/workflow_service.rb +1 -0
- data/lib/dor/workflow_version.rb +1 -1
- data/spec/workflow_service_spec.rb +78 -77
- metadata +39 -53
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 95ac5b55e85b0888494137002b9ddc6bec371154
|
4
|
+
data.tar.gz: d1d9a154300e1ea5fa93465dc750eab338540cae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dc5c11825381c2121d155ec476904f3ad09a57eba04d00bc5b89812b12ab0b1b7ab027766f02a2d46bb8e901ff44b194c0137362cc3fc31e1a919ff463628824
|
7
|
+
data.tar.gz: 64cf49461fbeb5fb24f8c950000644762aedb9bfb1779980b9b8440529606ee66092dbbc5322af49fbfbc9e54d925c2f9b3dc3f3519b634d09cc34f3d519e5db
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -3,11 +3,6 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in dor-workflow-service.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
if RUBY_VERSION < '1.9'
|
7
|
-
gem 'activesupport', "< 4.0"
|
8
|
-
gem 'nokogiri', "< 1.6"
|
9
|
-
end
|
10
|
-
|
11
6
|
group :development do
|
12
7
|
gem "debugger", :platform => :ruby_19
|
13
8
|
end
|
@@ -14,10 +14,10 @@ Gem::Specification.new do |gem|
|
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split($/)
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
-
gem.test_files = gem.files.grep(%r{^(
|
17
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.add_dependency "activesupport", '
|
20
|
+
gem.add_dependency "activesupport", '>= 3.2.1', '< 4.2.2'
|
21
21
|
gem.add_dependency "nokogiri", '~> 1.6.0'
|
22
22
|
gem.add_dependency "rest-client", '~> 1.6.7'
|
23
23
|
gem.add_dependency "confstruct", '~> 0.2.7'
|
@@ -26,5 +26,5 @@ Gem::Specification.new do |gem|
|
|
26
26
|
gem.add_development_dependency "rspec"
|
27
27
|
gem.add_development_dependency "yard"
|
28
28
|
gem.add_development_dependency "redcarpet"
|
29
|
-
gem.add_development_dependency "equivalent-xml", '~> 0.
|
29
|
+
gem.add_development_dependency "equivalent-xml", '~> 0.5.1'
|
30
30
|
end
|
data/lib/dor/workflow_version.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
require 'dor-workflow-service'
|
3
3
|
require 'equivalent-xml'
|
4
|
+
require 'equivalent-xml/rspec_matchers'
|
4
5
|
|
5
6
|
describe Dor::WorkflowService do
|
6
7
|
|
@@ -32,29 +33,29 @@ describe Dor::WorkflowService do
|
|
32
33
|
@druid = 'druid:123'
|
33
34
|
|
34
35
|
@mock_logger = double('logger').as_null_object
|
35
|
-
Rails.
|
36
|
+
allow(Rails).to receive(:logger).and_return(@mock_logger)
|
36
37
|
|
37
38
|
@mock_resource = double('mock_rest_client_resource')
|
38
|
-
@mock_resource.
|
39
|
-
@mock_resource.
|
40
|
-
RestClient::Resource.
|
39
|
+
allow(@mock_resource).to receive(:[]).and_return(@mock_resource)
|
40
|
+
allow(@mock_resource).to receive(:options).and_return( {} )
|
41
|
+
allow(RestClient::Resource).to receive(:new).and_return(@mock_resource)
|
41
42
|
Dor::WorkflowService.configure 'https://dortest.stanford.edu/workflow'
|
42
43
|
end
|
43
44
|
|
44
45
|
describe "#create_workflow" do
|
45
46
|
it "should pass workflow xml to the DOR workflow service and return the URL to the workflow" do
|
46
|
-
@mock_resource.
|
47
|
+
expect(@mock_resource).to receive(:put).with(wf_xml_label, anything()).and_return('')
|
47
48
|
Dor::WorkflowService.create_workflow(@repo, @druid, 'etdSubmitWF', wf_xml)
|
48
49
|
end
|
49
50
|
|
50
51
|
it "should log an error and return false if the PUT to the DOR workflow service throws an exception" do
|
51
52
|
ex = Exception.new("exception thrown")
|
52
|
-
@mock_resource.
|
53
|
-
|
53
|
+
expect(@mock_resource).to receive(:put).and_raise(ex)
|
54
|
+
expect{ Dor::WorkflowService.create_workflow(@repo, @druid, 'etdSubmitWF', wf_xml) }.to raise_error(Exception, "exception thrown")
|
54
55
|
end
|
55
56
|
|
56
57
|
it "sets the create-ds param to the value of the passed in options hash" do
|
57
|
-
@mock_resource.
|
58
|
+
expect(@mock_resource).to receive(:put).with(wf_xml_label, :content_type => 'application/xml',
|
58
59
|
:params => {'create-ds' => false}).and_return('')
|
59
60
|
Dor::WorkflowService.create_workflow(@repo, @druid, 'etdSubmitWF', wf_xml, :create_ds => false)
|
60
61
|
end
|
@@ -78,7 +79,7 @@ describe Dor::WorkflowService do
|
|
78
79
|
</workflow>
|
79
80
|
XML
|
80
81
|
|
81
|
-
Dor::WorkflowService.send(:add_lane_id_to_workflow_xml, 'lane1', wf_xml).
|
82
|
+
expect(Dor::WorkflowService.send(:add_lane_id_to_workflow_xml, 'lane1', wf_xml)).to be_equivalent_to(expected)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
@@ -89,56 +90,56 @@ describe Dor::WorkflowService do
|
|
89
90
|
|
90
91
|
it "should update workflow status and return true if successful" do
|
91
92
|
built_xml = "<?xml version=\"1.0\"?>\n<process name=\"reader-approval\" status=\"completed\" elapsed=\"0\" note=\"annotation\" version=\"2\" laneId=\"lane2\"/>\n"
|
92
|
-
@mock_resource.
|
93
|
-
Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane2').
|
93
|
+
expect(@mock_resource).to receive(:put).with(built_xml, { :content_type => 'application/xml' }).and_return('')
|
94
|
+
expect(Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane2')).to be_truthy
|
94
95
|
end
|
95
96
|
|
96
97
|
it "should return false if the PUT to the DOR workflow service throws an exception" do
|
97
98
|
ex = Exception.new("exception thrown")
|
98
|
-
@mock_resource.
|
99
|
-
|
99
|
+
expect(@mock_resource).to receive(:put).with(@xml_re, { :content_type => 'application/xml' }).and_raise(ex)
|
100
|
+
expect{ Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed") }.to raise_error(Exception, "exception thrown")
|
100
101
|
end
|
101
102
|
|
102
103
|
it "performs a conditional update when current-status is passed as a parameter" do
|
103
|
-
@mock_resource.
|
104
|
-
@mock_resource.
|
105
|
-
Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane1', :current_status => 'queued').
|
104
|
+
expect(@mock_resource).to receive(:[]).with("dor/objects/druid:123/workflows/etdSubmitWF/reader-approval?current-status=queued")
|
105
|
+
expect(@mock_resource).to receive(:put).with(@xml_re, { :content_type => 'application/xml' }).and_return('')
|
106
|
+
expect(Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed", :version => 2, :note => 'annotation', :lane_id => 'lane1', :current_status => 'queued')).to be_truthy
|
106
107
|
end
|
107
108
|
end
|
108
109
|
|
109
110
|
describe "#update_workflow_error_status" do
|
110
111
|
it "should update workflow status to error and return true if successful" do
|
111
|
-
@mock_resource.
|
112
|
+
expect(@mock_resource).to receive(:put).with(/status="error" errorMessage="Some exception" errorText="The optional stacktrace"/, { :content_type => 'application/xml' }).and_return('')
|
112
113
|
Dor::WorkflowService.update_workflow_error_status(@repo, @druid, "etdSubmitWF", "reader-approval", "Some exception", :error_text =>"The optional stacktrace")
|
113
114
|
end
|
114
115
|
|
115
116
|
it "should return false if the PUT to the DOR workflow service throws an exception" do
|
116
117
|
ex = Exception.new("exception thrown")
|
117
|
-
@mock_resource.
|
118
|
-
|
118
|
+
expect(@mock_resource).to receive(:put).with(/status="completed"/, { :content_type => 'application/xml' }).and_raise(ex)
|
119
|
+
expect{ Dor::WorkflowService.update_workflow_status(@repo, @druid, "etdSubmitWF", "reader-approval", "completed") }.to raise_error(Exception, "exception thrown")
|
119
120
|
end
|
120
121
|
end
|
121
122
|
|
122
123
|
describe "#get_workflow_status" do
|
123
124
|
it "parses workflow xml and returns status as a string" do
|
124
|
-
@mock_resource.
|
125
|
-
Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'etdSubmitWF', 'registrar-approval').
|
125
|
+
expect(@mock_resource).to receive(:get).and_return('<process name="registrar-approval" status="completed" />')
|
126
|
+
expect(Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'etdSubmitWF', 'registrar-approval')).to eq('completed')
|
126
127
|
end
|
127
128
|
|
128
129
|
it "should throw an exception if it fails for any reason" do
|
129
130
|
ex = Exception.new("exception thrown")
|
130
|
-
@mock_resource.
|
131
|
+
expect(@mock_resource).to receive(:get).and_raise(ex)
|
131
132
|
|
132
|
-
|
133
|
+
expect{ Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'etdSubmitWF', 'registrar-approval') }.to raise_error(Exception, "exception thrown")
|
133
134
|
end
|
134
135
|
|
135
136
|
it "should throw an exception if it cannot parse the response" do
|
136
|
-
@mock_resource.
|
137
|
-
|
137
|
+
expect(@mock_resource).to receive(:get).and_return('something not xml')
|
138
|
+
expect{ Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'etdSubmitWF', 'registrar-approval') }.to raise_error(Exception, "Unable to parse response:\nsomething not xml")
|
138
139
|
end
|
139
140
|
it "should return nil if the workflow/process combination doesnt exist" do
|
140
|
-
@mock_resource.
|
141
|
-
Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'accessionWF', 'publish').
|
141
|
+
expect(@mock_resource).to receive(:get).and_return('<process name="registrar-approval" status="completed" />')
|
142
|
+
expect(Dor::WorkflowService.get_workflow_status('dor', 'druid:123', 'accessionWF', 'publish')).to eq(nil)
|
142
143
|
end
|
143
144
|
|
144
145
|
end
|
@@ -146,8 +147,8 @@ describe Dor::WorkflowService do
|
|
146
147
|
describe "#get_workflow_xml" do
|
147
148
|
it "returns the xml for a given repository, druid, and workflow" do
|
148
149
|
xml = '<workflow id="etdSubmitWF"><process name="registrar-approval" status="completed" /></workflow>'
|
149
|
-
@mock_resource.
|
150
|
-
Dor::WorkflowService.get_workflow_xml('dor', 'druid:123', 'etdSubmitWF').
|
150
|
+
expect(@mock_resource).to receive(:get).and_return(xml)
|
151
|
+
expect(Dor::WorkflowService.get_workflow_xml('dor', 'druid:123', 'etdSubmitWF')).to eq(xml)
|
151
152
|
end
|
152
153
|
end
|
153
154
|
|
@@ -160,13 +161,13 @@ describe Dor::WorkflowService do
|
|
160
161
|
<milestone date="2010-06-15T16:08:58-0700">released</milestone>
|
161
162
|
</lifecycle>
|
162
163
|
EOXML
|
163
|
-
@mock_resource.
|
164
|
-
Dor::WorkflowService.get_lifecycle('dor', 'druid:123', 'released').beginning_of_day.
|
164
|
+
expect(@mock_resource).to receive(:get).and_return(xml)
|
165
|
+
expect(Dor::WorkflowService.get_lifecycle('dor', 'druid:123', 'released').beginning_of_day).to eq(Time.parse('2010-06-15T16:08:58-0700').beginning_of_day)
|
165
166
|
end
|
166
167
|
|
167
168
|
it "returns nil if the milestone hasn't been reached yet" do
|
168
|
-
@mock_resource.
|
169
|
-
Dor::WorkflowService.get_lifecycle('dor', 'druid:abc', 'inprocess').
|
169
|
+
expect(@mock_resource).to receive(:get).and_return('<lifecycle/>')
|
170
|
+
expect(Dor::WorkflowService.get_lifecycle('dor', 'druid:abc', 'inprocess')).to be_nil
|
170
171
|
end
|
171
172
|
|
172
173
|
end
|
@@ -181,18 +182,18 @@ describe Dor::WorkflowService do
|
|
181
182
|
|
182
183
|
context "a query with one step completed and one waiting" do
|
183
184
|
it "creates the URI string with only the one completed step" do
|
184
|
-
@mock_resource.
|
185
|
-
@mock_resource.
|
186
|
-
Dor::WorkflowService.get_objects_for_workstep(@completed, @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow).
|
185
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}&lane-id=default")
|
186
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
187
|
+
expect(Dor::WorkflowService.get_objects_for_workstep(@completed, @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow)).to eq(['druid:ab123de4567','druid:ab123de9012'])
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
190
191
|
context "a query with TWO steps completed and one waiting" do
|
191
192
|
it "creates the URI string with the two completed steps correctly" do
|
192
193
|
second_completed="google-convert"
|
193
|
-
@mock_resource.
|
194
|
-
@mock_resource.
|
195
|
-
Dor::WorkflowService.get_objects_for_workstep([@completed,second_completed], @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow).
|
194
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{@repository}:#{@workflow}:#{@waiting}&completed=#{@repository}:#{@workflow}:#{@completed}&completed=#{@repository}:#{@workflow}:#{second_completed}&lane-id=default")
|
195
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
196
|
+
expect(Dor::WorkflowService.get_objects_for_workstep([@completed,second_completed], @waiting, 'default', :default_repository => @repository, :default_workflow => @workflow)).to eq(['druid:ab123de4567','druid:ab123de9012'])
|
196
197
|
end
|
197
198
|
end
|
198
199
|
|
@@ -206,9 +207,9 @@ describe Dor::WorkflowService do
|
|
206
207
|
completed3="ingest-transfer"
|
207
208
|
qualified_completed2 = "#{repo2}:#{workflow2}:#{completed2}"
|
208
209
|
qualified_completed3 = "#{repo2}:#{workflow2}:#{completed3}"
|
209
|
-
@mock_resource.
|
210
|
-
@mock_resource.
|
211
|
-
Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting).
|
210
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}&lane-id=default")
|
211
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
212
|
+
expect(Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting)).to eq(['druid:ab123de4567', 'druid:ab123de9012'])
|
212
213
|
end
|
213
214
|
|
214
215
|
it "same but with lane_id" do
|
@@ -220,9 +221,9 @@ describe Dor::WorkflowService do
|
|
220
221
|
completed3="ingest-transfer"
|
221
222
|
qualified_completed2 = "#{repo2}:#{workflow2}:#{completed2}"
|
222
223
|
qualified_completed3 = "#{repo2}:#{workflow2}:#{completed3}"
|
223
|
-
@mock_resource.
|
224
|
-
@mock_resource.
|
225
|
-
Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting, "lane1").
|
224
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&completed=#{qualified_completed2}&completed=#{qualified_completed3}&lane-id=lane1")
|
225
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="2"><object id="druid:ab123de4567"/><object id="druid:ab123de9012"/></objects>})
|
226
|
+
expect(Dor::WorkflowService.get_objects_for_workstep([qualified_completed, qualified_completed2, qualified_completed3], qualified_waiting, "lane1")).to eq([ 'druid:ab123de4567', 'druid:ab123de9012'])
|
226
227
|
end
|
227
228
|
|
228
229
|
it "creates the URI string with only one completed step passed in as a String" do
|
@@ -230,25 +231,25 @@ describe Dor::WorkflowService do
|
|
230
231
|
qualified_completed = "#{@repository}:#{@workflow}:#{@completed}"
|
231
232
|
repo2 = "sdr"
|
232
233
|
|
233
|
-
@mock_resource.
|
234
|
-
@mock_resource.
|
235
|
-
Dor::WorkflowService.get_objects_for_workstep(qualified_completed, qualified_waiting).
|
234
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&completed=#{qualified_completed}&lane-id=default")
|
235
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
236
|
+
expect(Dor::WorkflowService.get_objects_for_workstep(qualified_completed, qualified_waiting)).to eq(['druid:ab123de4567'])
|
236
237
|
end
|
237
238
|
|
238
239
|
it "creates the URI string without any completed steps, only waiting" do
|
239
240
|
qualified_waiting = "#{@repository}:#{@workflow}:#{@waiting}"
|
240
241
|
|
241
|
-
@mock_resource.
|
242
|
-
@mock_resource.
|
243
|
-
Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting).
|
242
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&lane-id=default")
|
243
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
244
|
+
expect(Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting)).to eq(['druid:ab123de4567'])
|
244
245
|
end
|
245
246
|
|
246
247
|
it "same but with lane_id" do
|
247
248
|
qualified_waiting = "#{@repository}:#{@workflow}:#{@waiting}"
|
248
249
|
|
249
|
-
@mock_resource.
|
250
|
-
@mock_resource.
|
251
|
-
Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting, "lane1").
|
250
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{qualified_waiting}&lane-id=lane1")
|
251
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="1"><object id="druid:ab123de4567"/></objects>})
|
252
|
+
expect(Dor::WorkflowService.get_objects_for_workstep(nil, qualified_waiting, "lane1")).to eq([ 'druid:ab123de4567' ])
|
252
253
|
end
|
253
254
|
end
|
254
255
|
end
|
@@ -259,16 +260,16 @@ describe Dor::WorkflowService do
|
|
259
260
|
workflow = "googleScannedBookWF"
|
260
261
|
completed = "google-download"
|
261
262
|
waiting = "process-content"
|
262
|
-
@mock_resource.
|
263
|
-
@mock_resource.
|
264
|
-
Dor::WorkflowService.get_objects_for_workstep(completed, waiting, 'default', :default_repository => repository, :default_workflow => workflow).
|
263
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue?waiting=#{repository}:#{workflow}:#{waiting}&completed=#{repository}:#{workflow}:#{completed}&lane-id=default")
|
264
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="0"/>})
|
265
|
+
expect(Dor::WorkflowService.get_objects_for_workstep(completed, waiting, 'default', :default_repository => repository, :default_workflow => workflow)).to eq([])
|
265
266
|
end
|
266
267
|
end
|
267
268
|
|
268
269
|
describe "#delete_workflow" do
|
269
270
|
it "sends a delete request to the workflow service" do
|
270
|
-
@mock_resource.
|
271
|
-
@mock_resource.
|
271
|
+
expect(@mock_resource).to receive(:[]).with("#{@repo}/objects/#{@druid}/workflows/accessionWF")
|
272
|
+
expect(@mock_resource).to receive(:delete)
|
272
273
|
Dor::WorkflowService.delete_workflow(@repo, @druid, 'accessionWF')
|
273
274
|
end
|
274
275
|
end
|
@@ -276,10 +277,10 @@ describe Dor::WorkflowService do
|
|
276
277
|
it 'should include the version in with the milestones' do
|
277
278
|
xml='<?xml version="1.0" encoding="UTF-8"?><lifecycle objectId="druid:gv054hp4128"><milestone date="2012-01-26T21:06:54-0800" version="2">published</milestone></lifecycle>'
|
278
279
|
xml=Nokogiri::XML(xml)
|
279
|
-
Dor::WorkflowService.
|
280
|
+
allow(Dor::WorkflowService).to receive(:query_lifecycle).and_return(xml)
|
280
281
|
milestones=Dor::WorkflowService.get_milestones(@repo, @druid)
|
281
|
-
milestones.first[:milestone].
|
282
|
-
milestones.first[:version].
|
282
|
+
expect(milestones.first[:milestone]).to eq("published")
|
283
|
+
expect(milestones.first[:version]).to eq("2")
|
283
284
|
end
|
284
285
|
end
|
285
286
|
|
@@ -297,21 +298,21 @@ describe Dor::WorkflowService do
|
|
297
298
|
</workflows>
|
298
299
|
XML
|
299
300
|
|
300
|
-
Dor::WorkflowService.
|
301
|
+
allow(Dor::WorkflowService).to receive(:get_workflow_xml) { xml }
|
301
302
|
expect(Dor::WorkflowService.get_active_workflows('dor', 'druid:mw971zk1113')).to eq(['accessionWF'])
|
302
303
|
end
|
303
304
|
end
|
304
305
|
|
305
306
|
describe "#close_version" do
|
306
307
|
it "calls the versionClose endpoint with druid" do
|
307
|
-
@mock_resource.
|
308
|
-
@mock_resource.
|
308
|
+
expect(@mock_resource).to receive(:[]).with("dor/objects/druid:123/versionClose").and_return(@mock_resource)
|
309
|
+
expect(@mock_resource).to receive(:post).with('').and_return('')
|
309
310
|
Dor::WorkflowService.close_version(@repo, @druid)
|
310
311
|
end
|
311
312
|
|
312
313
|
it "optionally prevents creation of accessionWF" do
|
313
|
-
@mock_resource.
|
314
|
-
@mock_resource.
|
314
|
+
expect(@mock_resource).to receive(:[]).with("dor/objects/druid:123/versionClose?create-accession=false").and_return(@mock_resource)
|
315
|
+
expect(@mock_resource).to receive(:post).with('').and_return('')
|
315
316
|
Dor::WorkflowService.close_version(@repo, @druid, false)
|
316
317
|
end
|
317
318
|
end
|
@@ -324,22 +325,22 @@ describe Dor::WorkflowService do
|
|
324
325
|
<workflow laneId="lane2" note="annotation" lifecycle="in-process" errorText="stacktrace" errorMessage="NullPointerException" elapsed="1.173" repository="dor" attempts="0" datetime="2008-11-15T13:30:00-0800" status="waiting" process="jp2-create" name="assemblyWF" druid="dr:456"/>
|
325
326
|
</workflows>
|
326
327
|
XML
|
327
|
-
@mock_resource.
|
328
|
-
@mock_resource.
|
328
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue/all_queued?repository=dor&hours-ago=24&limit=100")
|
329
|
+
expect(@mock_resource).to receive(:get).and_return(xml)
|
329
330
|
|
330
331
|
ah = Dor::WorkflowService.get_stale_queued_workflows 'dor', :hours_ago => 24, :limit => 100
|
331
332
|
expected = [ { :workflow => 'accessionWF', :step => 'content-metadata', :druid => 'dr:123', :lane_id => 'lane1'},
|
332
333
|
{ :workflow => 'assemblyWF', :step => 'jp2-create', :druid => 'dr:456', :lane_id => 'lane2'} ]
|
333
|
-
ah.
|
334
|
+
expect(ah).to eql(expected)
|
334
335
|
end
|
335
336
|
end
|
336
337
|
|
337
338
|
describe ".count_stale_queued_workflows" do
|
338
339
|
it "returns the number of queued workflow steps" do
|
339
|
-
@mock_resource.
|
340
|
-
@mock_resource.
|
340
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue/all_queued?repository=dor&hours-ago=48&count-only=true")
|
341
|
+
expect(@mock_resource).to receive(:get).and_return(%{<objects count="10"/>})
|
341
342
|
|
342
|
-
Dor::WorkflowService.count_stale_queued_workflows('dor', :hours_ago => 48).
|
343
|
+
expect(Dor::WorkflowService.count_stale_queued_workflows('dor', :hours_ago => 48)).to eq(10)
|
343
344
|
end
|
344
345
|
end
|
345
346
|
|
@@ -352,11 +353,11 @@ describe Dor::WorkflowService do
|
|
352
353
|
</lanes>
|
353
354
|
XML
|
354
355
|
|
355
|
-
@mock_resource.
|
356
|
-
@mock_resource.
|
356
|
+
expect(@mock_resource).to receive(:[]).with("workflow_queue/lane_ids?step=dor:accessionWF:shelve")
|
357
|
+
expect(@mock_resource).to receive(:get).and_return(xml)
|
357
358
|
|
358
|
-
Dor::WorkflowService.get_lane_ids('dor', 'accessionWF', 'shelve').
|
359
|
+
expect(Dor::WorkflowService.get_lane_ids('dor', 'accessionWF', 'shelve')).to eq(["lane1", "lane2"])
|
359
360
|
end
|
360
361
|
end
|
361
362
|
|
362
|
-
end
|
363
|
+
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dor-workflow-service
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
5
|
-
prerelease:
|
4
|
+
version: 1.7.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Willy Mene
|
@@ -10,152 +9,140 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2015-01-21 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: activesupport
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
20
|
+
version: 3.2.1
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 4.2.2
|
23
24
|
type: :runtime
|
24
25
|
prerelease: false
|
25
26
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
27
|
requirements:
|
28
|
-
- -
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 3.2.1
|
31
|
+
- - "<"
|
29
32
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
33
|
+
version: 4.2.2
|
31
34
|
- !ruby/object:Gem::Dependency
|
32
35
|
name: nokogiri
|
33
36
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
37
|
requirements:
|
36
|
-
- - ~>
|
38
|
+
- - "~>"
|
37
39
|
- !ruby/object:Gem::Version
|
38
40
|
version: 1.6.0
|
39
41
|
type: :runtime
|
40
42
|
prerelease: false
|
41
43
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
44
|
requirements:
|
44
|
-
- - ~>
|
45
|
+
- - "~>"
|
45
46
|
- !ruby/object:Gem::Version
|
46
47
|
version: 1.6.0
|
47
48
|
- !ruby/object:Gem::Dependency
|
48
49
|
name: rest-client
|
49
50
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 1.6.7
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
58
|
requirements:
|
60
|
-
- - ~>
|
59
|
+
- - "~>"
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: 1.6.7
|
63
62
|
- !ruby/object:Gem::Dependency
|
64
63
|
name: confstruct
|
65
64
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
65
|
requirements:
|
68
|
-
- - ~>
|
66
|
+
- - "~>"
|
69
67
|
- !ruby/object:Gem::Version
|
70
68
|
version: 0.2.7
|
71
69
|
type: :runtime
|
72
70
|
prerelease: false
|
73
71
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
72
|
requirements:
|
76
|
-
- - ~>
|
73
|
+
- - "~>"
|
77
74
|
- !ruby/object:Gem::Version
|
78
75
|
version: 0.2.7
|
79
76
|
- !ruby/object:Gem::Dependency
|
80
77
|
name: rake
|
81
78
|
requirement: !ruby/object:Gem::Requirement
|
82
|
-
none: false
|
83
79
|
requirements:
|
84
|
-
- -
|
80
|
+
- - ">="
|
85
81
|
- !ruby/object:Gem::Version
|
86
82
|
version: '0'
|
87
83
|
type: :development
|
88
84
|
prerelease: false
|
89
85
|
version_requirements: !ruby/object:Gem::Requirement
|
90
|
-
none: false
|
91
86
|
requirements:
|
92
|
-
- -
|
87
|
+
- - ">="
|
93
88
|
- !ruby/object:Gem::Version
|
94
89
|
version: '0'
|
95
90
|
- !ruby/object:Gem::Dependency
|
96
91
|
name: rspec
|
97
92
|
requirement: !ruby/object:Gem::Requirement
|
98
|
-
none: false
|
99
93
|
requirements:
|
100
|
-
- -
|
94
|
+
- - ">="
|
101
95
|
- !ruby/object:Gem::Version
|
102
96
|
version: '0'
|
103
97
|
type: :development
|
104
98
|
prerelease: false
|
105
99
|
version_requirements: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
100
|
requirements:
|
108
|
-
- -
|
101
|
+
- - ">="
|
109
102
|
- !ruby/object:Gem::Version
|
110
103
|
version: '0'
|
111
104
|
- !ruby/object:Gem::Dependency
|
112
105
|
name: yard
|
113
106
|
requirement: !ruby/object:Gem::Requirement
|
114
|
-
none: false
|
115
107
|
requirements:
|
116
|
-
- -
|
108
|
+
- - ">="
|
117
109
|
- !ruby/object:Gem::Version
|
118
110
|
version: '0'
|
119
111
|
type: :development
|
120
112
|
prerelease: false
|
121
113
|
version_requirements: !ruby/object:Gem::Requirement
|
122
|
-
none: false
|
123
114
|
requirements:
|
124
|
-
- -
|
115
|
+
- - ">="
|
125
116
|
- !ruby/object:Gem::Version
|
126
117
|
version: '0'
|
127
118
|
- !ruby/object:Gem::Dependency
|
128
119
|
name: redcarpet
|
129
120
|
requirement: !ruby/object:Gem::Requirement
|
130
|
-
none: false
|
131
121
|
requirements:
|
132
|
-
- -
|
122
|
+
- - ">="
|
133
123
|
- !ruby/object:Gem::Version
|
134
124
|
version: '0'
|
135
125
|
type: :development
|
136
126
|
prerelease: false
|
137
127
|
version_requirements: !ruby/object:Gem::Requirement
|
138
|
-
none: false
|
139
128
|
requirements:
|
140
|
-
- -
|
129
|
+
- - ">="
|
141
130
|
- !ruby/object:Gem::Version
|
142
131
|
version: '0'
|
143
132
|
- !ruby/object:Gem::Dependency
|
144
133
|
name: equivalent-xml
|
145
134
|
requirement: !ruby/object:Gem::Requirement
|
146
|
-
none: false
|
147
135
|
requirements:
|
148
|
-
- - ~>
|
136
|
+
- - "~>"
|
149
137
|
- !ruby/object:Gem::Version
|
150
|
-
version: 0.
|
138
|
+
version: 0.5.1
|
151
139
|
type: :development
|
152
140
|
prerelease: false
|
153
141
|
version_requirements: !ruby/object:Gem::Requirement
|
154
|
-
none: false
|
155
142
|
requirements:
|
156
|
-
- - ~>
|
143
|
+
- - "~>"
|
157
144
|
- !ruby/object:Gem::Version
|
158
|
-
version: 0.
|
145
|
+
version: 0.5.1
|
159
146
|
description: Enables Ruby manipulation of the DOR Workflow Service via its REST API
|
160
147
|
email:
|
161
148
|
- wmene@stanford.edu
|
@@ -164,9 +151,10 @@ executables:
|
|
164
151
|
extensions: []
|
165
152
|
extra_rdoc_files: []
|
166
153
|
files:
|
167
|
-
- .gitignore
|
168
|
-
- .
|
169
|
-
- .
|
154
|
+
- ".gitignore"
|
155
|
+
- ".rspec"
|
156
|
+
- ".travis.yml"
|
157
|
+
- ".yardopts"
|
170
158
|
- Gemfile
|
171
159
|
- LICENSE.txt
|
172
160
|
- README.md
|
@@ -180,29 +168,27 @@ files:
|
|
180
168
|
- spec/workflow_service_spec.rb
|
181
169
|
homepage: https://consul.stanford.edu/display/DOR/DOR+services#DORservices-initializeworkflow
|
182
170
|
licenses: []
|
171
|
+
metadata: {}
|
183
172
|
post_install_message:
|
184
173
|
rdoc_options: []
|
185
174
|
require_paths:
|
186
175
|
- lib
|
187
176
|
required_ruby_version: !ruby/object:Gem::Requirement
|
188
|
-
none: false
|
189
177
|
requirements:
|
190
|
-
- -
|
178
|
+
- - ">="
|
191
179
|
- !ruby/object:Gem::Version
|
192
180
|
version: '0'
|
193
181
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
|
-
none: false
|
195
182
|
requirements:
|
196
|
-
- -
|
183
|
+
- - ">="
|
197
184
|
- !ruby/object:Gem::Version
|
198
185
|
version: '0'
|
199
186
|
requirements: []
|
200
187
|
rubyforge_project:
|
201
|
-
rubygems_version:
|
188
|
+
rubygems_version: 2.4.5
|
202
189
|
signing_key:
|
203
|
-
specification_version:
|
190
|
+
specification_version: 4
|
204
191
|
summary: Provides convenience methods to work with the DOR Workflow Service
|
205
192
|
test_files:
|
206
193
|
- spec/spec_helper.rb
|
207
194
|
- spec/workflow_service_spec.rb
|
208
|
-
has_rdoc:
|