<s> import subprocess <EOL> import pytest <EOL> from mock import Mock , patch <EOL> from ceph_deploy . cli import _main as main <EOL> from ceph_deploy . tests . directory import directory <EOL> def test_bad_no_conf ( tmpdir , cli ) : <EOL> with pytest . raises ( cli . Failed ) as err : <EOL> with cli ( <EOL> args = [ '<STR_LIT>' , '<STR_LIT>' ] , <EOL> stderr = subprocess . PIPE , <EOL> ) as p : <EOL> result = p . stderr . read ( ) <EOL> assert '<STR_LIT>' in result <EOL> assert '<STR_LIT>' in result <EOL> assert err . value . status == <NUM_LIT:2> <EOL> def make_fake_connection ( platform_information = None ) : <EOL> get_connection = Mock ( ) <EOL> get_connection . return_value = get_connection <EOL> get_connection . remote_module . platform_information = Mock ( <EOL> return_value = platform_information ) <EOL> return get_connection <EOL> def test_new ( tmpdir , capsys ) : <EOL> with tmpdir . join ( '<STR_LIT>' ) . open ( '<STR_LIT:w>' ) as f : <EOL> f . write ( """<STR_LIT>""" ) <EOL> fake_ip_addresses = lambda x : [ '<STR_LIT>' ] <EOL> try : <EOL> with patch ( '<STR_LIT>' , fake_ip_addresses ) : <EOL> with patch ( '<STR_LIT>' , lambda x : '<STR_LIT>' ) : <EOL> with patch ( '<STR_LIT>' , lambda : lambda x : x ) : <EOL> with patch ( '<STR_LIT>' ) : <EOL> with directory ( str ( tmpdir ) ) : <EOL> main ( [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> except SystemExit as e : <EOL> raise AssertionError ( '<STR_LIT>' , e ) <EOL> out , err = capsys . readouterr ( ) <EOL> err = err . lower ( ) <EOL> assert '<STR_LIT>' in err <EOL> assert '<STR_LIT>' in err <EOL> assert '<STR_LIT>' in err <EOL> assert "<STR_LIT>" in err <EOL> assert "<STR_LIT>" in err </s>
