Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
1ca8cb85
Commit
1ca8cb85
authored
9 years ago
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing up v2 unit tests
parent
361eb291
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
lib/ansible/playbook/block.py
+1
-1
test/units/executor/test_play_iterator.py
+16
-6
test/units/playbook/test_play.py
+3
-3
test/units/vars/test_variable_manager.py
+1
-0
No files found.
lib/ansible/playbook/block.py
View file @
1ca8cb85
...
...
@@ -66,7 +66,7 @@ class Block(Base, Become, Conditional, Taggable):
return
all_vars
@staticmethod
def
load
(
data
,
play
,
parent_block
=
None
,
role
=
None
,
task_include
=
None
,
use_handlers
=
False
,
variable_manager
=
None
,
loader
=
None
):
def
load
(
data
,
play
=
None
,
parent_block
=
None
,
role
=
None
,
task_include
=
None
,
use_handlers
=
False
,
variable_manager
=
None
,
loader
=
None
):
b
=
Block
(
play
=
play
,
parent_block
=
parent_block
,
role
=
role
,
task_include
=
task_include
,
use_handlers
=
use_handlers
)
return
b
.
load_data
(
data
,
variable_manager
=
variable_manager
,
loader
=
loader
)
...
...
This diff is collapsed.
Click to expand it.
test/units/executor/test_play_iterator.py
View file @
1ca8cb85
...
...
@@ -23,6 +23,7 @@ from ansible.compat.tests import unittest
from
ansible.compat.tests.mock
import
patch
,
MagicMock
from
ansible.errors
import
AnsibleError
,
AnsibleParserError
from
ansible.executor.connection_info
import
ConnectionInformation
from
ansible.executor.play_iterator
import
PlayIterator
from
ansible.playbook
import
Playbook
...
...
@@ -67,19 +68,28 @@ class TestPlayIterator(unittest.TestCase):
inventory
.
get_hosts
.
return_value
=
hosts
inventory
.
filter_hosts
.
return_value
=
hosts
itr
=
PlayIterator
(
inventory
,
p
.
_entries
[
0
])
task
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
connection_info
=
ConnectionInformation
(
play
=
p
.
_entries
[
0
])
itr
=
PlayIterator
(
inventory
=
inventory
,
play
=
p
.
_entries
[
0
],
connection_info
=
connection_info
,
all_vars
=
dict
(),
)
(
host_state
,
task
)
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
print
(
task
)
self
.
assertIsNotNone
(
task
)
task
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
(
host_state
,
task
)
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
print
(
task
)
self
.
assertIsNotNone
(
task
)
task
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
(
host_state
,
task
)
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
print
(
task
)
self
.
assertIsNotNone
(
task
)
task
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
(
host_state
,
task
)
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
print
(
task
)
self
.
assertIsNotNone
(
task
)
task
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
(
host_state
,
task
)
=
itr
.
get_next_task_for_host
(
hosts
[
0
])
print
(
task
)
self
.
assertIsNone
(
task
)
This diff is collapsed.
Click to expand it.
test/units/playbook/test_play.py
View file @
1ca8cb85
...
...
@@ -23,9 +23,9 @@ from ansible.compat.tests import unittest
from
ansible.compat.tests.mock
import
patch
,
MagicMock
from
ansible.errors
import
AnsibleError
,
AnsibleParserError
from
ansible.playbook.block
import
Block
from
ansible.playbook.play
import
Play
from
ansible.playbook.role
import
Role
from
ansible.playbook.task
import
Task
from
units.mock.loader
import
DictDataLoader
...
...
@@ -39,7 +39,7 @@ class TestPlay(unittest.TestCase):
def
test_empty_play
(
self
):
p
=
Play
.
load
(
dict
())
self
.
assertEqual
(
str
(
p
),
"PLAY:
<no name specified>
"
)
self
.
assertEqual
(
str
(
p
),
"PLAY: "
)
def
test_basic_play
(
self
):
p
=
Play
.
load
(
dict
(
...
...
@@ -129,4 +129,4 @@ class TestPlay(unittest.TestCase):
tasks
=
p
.
compile
()
self
.
assertEqual
(
len
(
tasks
),
1
)
self
.
assertIsInstance
(
tasks
[
0
],
Tas
k
)
self
.
assertIsInstance
(
tasks
[
0
],
Bloc
k
)
This diff is collapsed.
Click to expand it.
test/units/vars/test_variable_manager.py
View file @
1ca8cb85
...
...
@@ -137,6 +137,7 @@ class TestVariableManager(unittest.TestCase):
fake_loader
=
DictDataLoader
({})
mock_task
=
MagicMock
()
mock_task
.
_role
=
None
mock_task
.
get_vars
.
return_value
=
dict
(
foo
=
"bar"
)
v
=
VariableManager
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment