Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F3942543
test_forest.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
test_forest.py
View Options
#!/usr/bin/env python3
from
importlib.machinery
import
SourceFileLoader
import
unittest
salt_test_case
=
SourceFileLoader
(
"salt_test_case"
,
"salt_test_case.py"
)
.
load_module
()
forest
=
SourceFileLoader
(
"forest"
,
"../_modules/forest.py"
)
.
load_module
()
class
Testinstance
(
unittest
.
TestCase
,
salt_test_case
.
SaltTestCase
):
def
setUp
(
self
):
self
.
initialize_mocks
()
self
.
instance
=
forest
self
.
mock_pillar
(
"data/forests.yaml"
)
self
.
mock_grains
()
self
.
grains
[
"id"
]
=
"egladil"
def
test_exists
(
self
):
self
.
assertTrue
(
forest
.
exists
(
"lothlorien"
))
self
.
assertFalse
(
forest
.
exists
(
"notexisting"
))
def
test_get
(
self
):
self
.
assertEqual
(
"lothlorien"
,
forest
.
get
())
def
test_get_when_key_not_exists
(
self
):
self
.
grains
[
"id"
]
=
"notexisting"
self
.
assertRaises
(
KeyError
,
forest
.
get
)
def
test_list_groups
(
self
):
self
.
assertEqual
([
"caras_galadhon"
,
"ubiquity"
],
sorted
(
forest
.
list_groups
()))
def
test_list_groups_when_there_are_none_for_the_forest
(
self
):
self
.
grains
[
"id"
]
=
"entwash"
self
.
assertEqual
([
"ubiquity"
],
forest
.
list_groups
())
def
test_get_groups
(
self
):
self
.
assertEqual
(
[
"caras_galadhon"
,
"ubiquity"
],
sorted
(
forest
.
get_groups
()
.
keys
())
)
def
test_list_users
(
self
):
self
.
assertEqual
([
"amdir"
,
"amroth"
],
sorted
(
forest
.
list_users
()))
def
test_get_users
(
self
):
self
.
assertEqual
([
"amdir"
,
"amroth"
],
sorted
(
forest
.
get_users
()
.
keys
()))
if
__name__
==
"__main__"
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Thu, Dec 26, 16:28 (20 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2285373
Default Alt Text
test_forest.py (1 KB)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment