<s> from unittest . mock import Mock , call , ANY <EOL> from app . client . service_runner import ServiceRunner , ServiceRunError <EOL> from test . framework . base_unit_test_case import BaseUnitTestCase <EOL> class TestServiceRunner ( BaseUnitTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( ) . setUp ( ) <EOL> self . mock_Popen = self . patch ( '<STR_LIT>' ) <EOL> self . mock_Network = self . patch ( '<STR_LIT>' ) <EOL> self . mock_time = self . patch ( '<STR_LIT>' ) <EOL> def test_run_master_invokes_popen ( self ) : <EOL> self . mock_time . time . side_effect = range ( <NUM_LIT:1000> ) <EOL> mock_network = self . mock_Network . return_value <EOL> mock_network . get . return_value = Mock ( ok = False ) <EOL> try : <EOL> service_runner = ServiceRunner ( '<STR_LIT>' ) <EOL> service_runner . run_master ( ) <EOL> except ServiceRunError : <EOL> pass <EOL> self . assertEqual ( call ( [ ANY , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:1>' ] , stdout = ANY ) , self . mock_Popen . call_args ) <EOL> def test_run_master_does_not_invoke_popen_if_resp_is_ok ( self ) : <EOL> mock_network = self . mock_Network . return_value <EOL> mock_network . get . return_value = Mock ( ok = True ) <EOL> try : <EOL> service_runner = ServiceRunner ( '<STR_LIT>' ) <EOL> service_runner . run_master ( ) <EOL> except ServiceRunError : <EOL> pass <EOL> assert not self . mock_Popen . called </s>
