This repository has been archived by the owner on May 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
198 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
module AnsibleTowerClient | ||
class MockApi | ||
module WorkflowJob | ||
def self.collection | ||
[ | ||
{ | ||
"id": 792, | ||
"type": "workflow_job", | ||
"url": "/api/v1/workflow_jobs/792/", | ||
"related": { | ||
"created_by": "/api/v1/users/1/", | ||
"unified_job_template": "/api/v1/workflow_job_templates/345/", | ||
"workflow_job_template": "/api/v1/workflow_job_templates/345/", | ||
"notifications": "/api/v1/workflow_jobs/792/notifications/", | ||
"workflow_nodes": "/api/v1/workflow_jobs/792/workflow_nodes/", | ||
"labels": "/api/v1/workflow_jobs/792/labels/", | ||
"activity_stream": "/api/v1/workflow_jobs/792/activity_stream/", | ||
"relaunch": "/api/v1/workflow_jobs/792/relaunch/", | ||
"cancel": "/api/v1/workflow_jobs/792/cancel/" | ||
}, | ||
"summary_fields": { | ||
"instance_group": { | ||
"id": 1, | ||
"name": "tower" | ||
}, | ||
"workflow_job_template": { | ||
"id": 345, | ||
"name": "Demo-workflow (a expln)", | ||
"description": "" | ||
}, | ||
"unified_job_template": { | ||
"id": 345, | ||
"name": "Demo-workflow (a expln)", | ||
"description": "", | ||
"unified_job_type": "workflow_job" | ||
}, | ||
"created_by": { | ||
"id": 1, | ||
"username": "admin", | ||
"first_name": "", | ||
"last_name": "" | ||
}, | ||
"user_capabilities": { | ||
"start": true, | ||
"delete": true | ||
}, | ||
"labels": { | ||
"count": 0, | ||
"results": [] | ||
} | ||
}, | ||
"created": "2018-06-20T20:01:10.696Z", | ||
"modified": "2018-06-20T20:01:32.763Z", | ||
"name": "Demo-workflow (a expln)", | ||
"description": "", | ||
"unified_job_template": 345, | ||
"launch_type": "relaunch", | ||
"status": "successful", | ||
"failed": false, | ||
"started": "2018-06-20T20:01:10.873367Z", | ||
"finished": "2018-06-20T20:01:32.758097Z", | ||
"elapsed": 21.885, | ||
"job_args": "", | ||
"job_cwd": "", | ||
"job_env": {}, | ||
"job_explanation": "", | ||
"result_stdout": "stdout capture is missing", | ||
"result_traceback": "", | ||
"workflow_job_template": 345, | ||
"extra_vars": "{\"colors\": [\"red\", \"blue\"], \"name\": \"test abc\"}", | ||
"allow_simultaneous": false | ||
} | ||
] | ||
end | ||
|
||
def self.response | ||
{ | ||
"count" => collection.length, | ||
"next" => nil, | ||
"previous" => nil, | ||
"results" => collection | ||
}.to_json | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
module AnsibleTowerClient | ||
class MockApi | ||
module WorkflowJobNode | ||
def self.collection | ||
[ | ||
{ | ||
"id": 1, | ||
"type": "workflow_job_node", | ||
"url": "/api/v1/workflow_job_nodes/1/", | ||
"related": { | ||
"unified_job_template": "/api/v1/job_templates/216/", | ||
"success_nodes": "/api/v1/workflow_job_nodes/1/success_nodes/", | ||
"failure_nodes": "/api/v1/workflow_job_nodes/1/failure_nodes/", | ||
"always_nodes": "/api/v1/workflow_job_nodes/1/always_nodes/", | ||
"job": "/api/v1/jobs/429/", | ||
"workflow_job": "/api/v1/workflow_jobs/428/" | ||
}, | ||
"summary_fields": { | ||
"workflow_job": { | ||
"id": 428, | ||
"name": "james-wf2", | ||
"description": "" | ||
}, | ||
"job": { | ||
"id": 429, | ||
"name": "Demo Job Template", | ||
"description": "", | ||
"status": "successful", | ||
"failed": false, | ||
"elapsed": 6.344 | ||
}, | ||
"unified_job_template": { | ||
"id": 216, | ||
"name": "Demo Job Template", | ||
"description": "", | ||
"unified_job_type": "job" | ||
} | ||
}, | ||
"created": "2018-05-17T13:13:48.022Z", | ||
"modified": "2018-05-17T13:13:51.562Z", | ||
"unified_job_template": 216, | ||
"success_nodes": [], | ||
"failure_nodes": [], | ||
"always_nodes": [ | ||
2 | ||
], | ||
"inventory": nil, | ||
"credential": nil, | ||
"job_type": nil, | ||
"job_tags": nil, | ||
"skip_tags": nil, | ||
"limit": nil, | ||
"job": 429, | ||
"workflow_job": 428 | ||
} | ||
] | ||
end | ||
|
||
def self.response | ||
{ | ||
"count" => collection.length, | ||
"next" => nil, | ||
"previous" => nil, | ||
"results" => collection | ||
}.to_json | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe AnsibleTowerClient::WorkflowJobNode do | ||
let(:url) { "example.com/api/v1/workflow_job_nodes" } | ||
let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new) } | ||
let(:raw_instance) { build(:response_instance, :workflow_job_node, :klass => described_class) } | ||
|
||
include_examples "Api Methods" | ||
include_examples "Crud Methods" | ||
|
||
it "#initialize instantiates an #{described_class} from a hash" do | ||
obj = api.workflow_job_nodes.all.first | ||
|
||
expect(obj).to be_a described_class | ||
expect(obj.id).to be_a Integer | ||
expect(obj.job_id).to be_a Integer | ||
expect(obj.workflow_job_id).to be_a Integer | ||
expect(obj.related).to be_a described_class::Related | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
describe AnsibleTowerClient::WorkflowJob do | ||
let(:url) { "example.com/api/v1/workflow_jobs" } | ||
let(:api) { AnsibleTowerClient::Api.new(AnsibleTowerClient::MockApi.new) } | ||
let(:raw_instance) { build(:response_instance, :workflow_job, :klass => described_class) } | ||
|
||
include_examples "Api Methods" | ||
include_examples "Crud Methods" | ||
|
||
it "#initialize instantiates an #{described_class} from a hash" do | ||
obj = api.workflow_jobs.all.first | ||
|
||
expect(obj).to be_a described_class | ||
expect(obj.id).to be_a Integer | ||
expect(obj.name).to be_a String | ||
expect(obj.workflow_job_nodes).to be_a Enumerator | ||
expect(obj.related).to be_a described_class::Related | ||
end | ||
end |