Skip to content

Commit

Permalink
Add job_complete? method
Browse files Browse the repository at this point in the history
  • Loading branch information
quadule committed Jul 7, 2015
1 parent 3847c2e commit b9dd5f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/cielo24/jobs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def job_info(job_id)
get_json("/api/job/info", {job_id: job_id})
end

# Public: Returns whether or not a job has completed.
#
# job_id - The job to check for completion.
#
# Returns true if the job is complete, false otherwise.
def job_complete?(job_id)
job_info(job_id)["JobStatus"] == "Complete"
end

# Public: Requests the status info for a particular task.
#
# job_id - The job containing the task to get info about.
Expand Down
16 changes: 16 additions & 0 deletions spec/jobs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@
end
end

describe "#job_complete?" do
it "returns true if the job has completed" do
pending("CANNOT GUARANTEE COMPLETED JOB IN SANDBOX") if test_sandbox?

stub_get_json("/api/job/info", {"JobStatus" => "Complete"})
expect(client.job_complete?("JOB123")).to be_true
end

it "returns false if the job hasn't completed" do
pending("CANNOT GUARANTEE INCOMPLETE JOB IN SANDBOX") if test_sandbox?

stub_get_json("/api/job/info", {"JobStatus" => "In Process"})
expect(client.job_complete?("JOB123")).to be_false
end
end

describe "#task_complete?" do
it "returns true if the task has completed" do
pending("CANNOT GUARANTEE COMPLETED JOB IN SANDBOX") if test_sandbox?
Expand Down

0 comments on commit b9dd5f9

Please sign in to comment.