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
d100db83
Commit
d100db83
authored
Sep 30, 2015
by
Abhijit Menon-Sen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic tests for expand_hostname_range
parent
838e71ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
test/units/inventory/test_inventory.py
+17
-0
No files found.
test/units/inventory/test_inventory.py
View file @
d100db83
...
...
@@ -26,6 +26,7 @@ from ansible.compat.tests.mock import patch, MagicMock
from
ansible.errors
import
AnsibleError
,
AnsibleParserError
from
ansible.inventory
import
Inventory
from
ansible.inventory.expand_hosts
import
expand_hostname_range
from
ansible.vars
import
VariableManager
from
units.mock.loader
import
DictDataLoader
...
...
@@ -71,6 +72,16 @@ class TestInventory(unittest.TestCase):
'a[1:]'
:
[(
'a'
,
(
1
,
-
1
)),
list
(
string
.
ascii_letters
[
1
:])],
}
ranges_to_expand
=
{
'a[1:2]'
:
[
'a1'
,
'a2'
],
'a[1:10:2]'
:
[
'a1'
,
'a3'
,
'a5'
,
'a7'
,
'a9'
],
'a[a:b]'
:
[
'aa'
,
'ab'
],
'a[a:i:3]'
:
[
'aa'
,
'ad'
,
'ag'
],
'a[a:b][c:d]'
:
[
'aac'
,
'aad'
,
'abc'
,
'abd'
],
'a[0:1][2:3]'
:
[
'a02'
,
'a03'
,
'a12'
,
'a13'
],
'a[a:b][2:3]'
:
[
'aa2'
,
'aa3'
,
'ab2'
,
'ab3'
],
}
def
setUp
(
self
):
v
=
VariableManager
()
fake_loader
=
DictDataLoader
({})
...
...
@@ -98,3 +109,9 @@ class TestInventory(unittest.TestCase):
r
[
0
][
1
]
)
)
def
test_expand_hostname_range
(
self
):
for
e
in
self
.
ranges_to_expand
:
r
=
self
.
ranges_to_expand
[
e
]
self
.
assertEqual
(
r
,
expand_hostname_range
(
e
))
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