Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F49450925
test_ids.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1012 B
Referenced Files
None
Subscribers
None
test_ids.py
View Options
#!/usr/bin/env python3
import
unittest
import
yaml
PILLAR_FILE
=
"../pillar/core/ids.sls"
class
TestIds
(
unittest
.
TestCase
):
def
setUp
(
self
):
with
open
(
PILLAR_FILE
,
"r"
)
as
fd
:
self
.
pillar
=
yaml
.
safe_load
(
fd
)
def
test_ids_are_integers
(
self
):
errors
=
[]
for
section
in
(
"uids"
,
"gids"
):
for
name
,
identifier
in
self
.
pillar
[
section
]
.
items
():
if
not
isinstance
(
identifier
,
int
):
errors
.
append
(
f
"{section}:{name} isn't an integer"
)
self
.
assertEqual
([],
errors
)
def
test_ids_are_unique_in_each_section
(
self
):
errors
=
[]
for
section
in
(
"uids"
,
"gids"
):
ids
=
list
(
self
.
pillar
[
section
]
.
values
())
duplicates
=
{
identifier
for
identifier
in
ids
if
ids
.
count
(
identifier
)
>
1
}
if
duplicates
:
errors
.
append
(
f
"{section} has duplicate IDs: {duplicates}"
)
self
.
assertEqual
([],
errors
)
if
__name__
==
"__main__"
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Mon, Sep 14, 08:49 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4066846
Default Alt Text
test_ids.py (1012 B)
Attached To
Mode
rOPS Nasqueron Operations
Attached
Detach File
Event Timeline
Log In to Comment