11#!/usr/bin/env python
2- from other .hsm .hsm import HierachicalStateMachine , UnsupportedMessageType ,\
3- UnsupportedState , UnsupportedTransition , Active , Standby , Suspect , Failed
4- from sys import version_info
5-
6- if version_info < (2 , 7 ): # pragma: no cover
7- import unittest2 as unittest
8- else :
9- import unittest
10-
2+ # -*- coding: utf-8 -*-
3+ import unittest
4+ from other .hsm .hsm import HierachicalStateMachine ,\
5+ UnsupportedMessageType , UnsupportedState ,\
6+ UnsupportedTransition , Active , Standby , Suspect
117try :
128 from unittest .mock import patch
139except ImportError :
@@ -62,9 +58,9 @@ def test_given_standby_on_message_switchover_shall_set_active(cls):
6258
6359 def test_given_standby_on_message_switchover_shall_call_hsm_methods (cls ):
6460 with patch .object (cls .hsm , '_perform_switchover' ) as mock_perform_switchover ,\
65- patch .object (cls .hsm , '_check_mate_status' ) as mock_check_mate_status ,\
66- patch .object (cls .hsm , '_send_switchover_response' ) as mock_send_switchover_response ,\
67- patch .object (cls .hsm , '_next_state' ) as mock_next_state :
61+ patch .object (cls .hsm , '_check_mate_status' ) as mock_check_mate_status ,\
62+ patch .object (cls .hsm , '_send_switchover_response' ) as mock_send_switchover_response ,\
63+ patch .object (cls .hsm , '_next_state' ) as mock_next_state :
6864 cls .hsm .on_message ('switchover' )
6965 cls .assertEqual (mock_perform_switchover .call_count , 1 )
7066 cls .assertEqual (mock_check_mate_status .call_count , 1 )
@@ -89,7 +85,3 @@ def test_given_standby_on_message_operator_inservice_shall_raise_exception_and_k
8985 with cls .assertRaises (UnsupportedTransition ) as context :
9086 cls .hsm .on_message ('operator inservice' )
9187 cls .assertEqual (isinstance (cls .hsm ._current_state , Standby ), True )
92-
93-
94- if __name__ == "__main__" :
95- unittest .main ()
0 commit comments