Page Menu
Home
ClusterLabs Projects
Search
Configure Global Search
Log In
Files
F3153767
fence_testing_test.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
fence_testing_test.py
View Options
#!/usr/bin/python
import
unittest
import
fence_testing
class
TestPrepareCommand
(
unittest
.
TestCase
):
DEVICE_MISSING_OPTION
=
"devices.d/invalid-missing_option.cfg"
DEVICE_CORRECT
=
"devices.d/true.cfg"
DEVICE_CORRECT_WITH_ACTION
=
"devices.d/true-with_action.cfg"
def
test_missing_device
(
self
):
self
.
assertRaises
(
fence_testing
.
_prepare_command
,
None
,
"getopt"
)
def
test_missing_option
(
self
):
self
.
assertRaises
(
AssertionError
,
fence_testing
.
_prepare_command
,
self
.
DEVICE_MISSING_OPTION
,
"stdin"
)
def
test_valid_methods
(
self
):
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"getopt"
)
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"longopt"
)
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"stdin"
)
def
test_invalid_method
(
self
):
self
.
assertRaises
(
AssertionError
,
fence_testing
.
_prepare_command
,
self
.
DEVICE_CORRECT
,
"invalid"
)
def
test_is_action_ignored
(
self
):
(
command1
,
_
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"getopt"
)
(
command2
,
_
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT_WITH_ACTION
,
"getopt"
)
self
.
assertEquals
(
command1
,
command2
)
def
test_is_stdin_empty
(
self
):
(
_
,
stdin
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"getopt"
)
self
.
assertEquals
(
None
,
stdin
)
(
_
,
stdin
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"longopt"
)
self
.
assertEquals
(
None
,
stdin
)
def
test_prepared_command_getopt
(
self
):
## Test also fallback to longopt if short is not present
(
command
,
_
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"getopt"
)
self
.
assertEquals
(
"/bin/true -l foo -p bar -a fence.example.com --plug 1"
,
command
)
def
test_prepared_command_longopt
(
self
):
(
command
,
_
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"longopt"
)
self
.
assertEquals
(
"/bin/true --username foo --password bar --ip fence.example.com --plug 1"
,
command
)
def
test_prepared_command_stdin
(
self
):
(
command
,
stdin
)
=
fence_testing
.
_prepare_command
(
self
.
DEVICE_CORRECT
,
"stdin"
)
self
.
assertEquals
(
"/bin/true"
,
command
)
self
.
assertEquals
(
"login=foo
\n
passwd=bar
\n
ipaddr=fence.example.com
\n
port=1
\n
"
,
stdin
)
class
TestTestAction
(
unittest
.
TestCase
):
def
test_valid_actions
(
self
):
pass
def
test_invalid_actions
(
self
):
pass
def
test_valid_return_code
(
self
):
pass
def
test_invalid_return_code
(
self
):
pass
def
test_valid_re_contains
(
self
):
pass
def
test_invalid_re_contains
(
self
):
pass
if
__name__
==
'__main__'
:
unittest
.
main
()
File Metadata
Details
Attached
Mime Type
text/x-script.python
Expires
Wed, Feb 26, 1:20 AM (1 d, 1 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1363911
Default Alt Text
fence_testing_test.py (2 KB)
Attached To
Mode
rF Fence Agents
Attached
Detach File
Event Timeline
Log In to Comment