From: Alfredo Deza Date: Wed, 31 Jul 2013 20:30:10 +0000 (-0400) Subject: patch socket on tests that call cli directly X-Git-Tag: v1.2~12^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=34b935d913a0b009bbb6cafa46dd7815457438b1;p=ceph-deploy.git patch socket on tests that call cli directly --- diff --git a/ceph_deploy/tests/test_cli_mon.py b/ceph_deploy/tests/test_cli_mon.py index 6df9096..81aa045 100644 --- a/ceph_deploy/tests/test_cli_mon.py +++ b/ceph_deploy/tests/test_cli_mon.py @@ -73,16 +73,17 @@ mon initial members = host1 mock_compiled[mon.create_mon].side_effect = _create_mon try: - with mock.patch('socket.getaddrinfo', fake_getaddrinfo): - with directory(str(tmpdir)): - main( - args=['-v', 'new', 'host1'], - namespace=ns, - ) - main( - args=['-v', 'mon', 'create', 'host1'], - namespace=ns, - ) + with mock.patch('ceph_deploy.new.socket.gethostbyname'): + with mock.patch('socket.getaddrinfo', fake_getaddrinfo): + with directory(str(tmpdir)): + main( + args=['-v', 'new', 'host1'], + namespace=ns, + ) + main( + args=['-v', 'mon', 'create', 'host1'], + namespace=ns, + ) except SystemExit as e: raise AssertionError('Unexpected exit: %s', e) out, err = capsys.readouterr() diff --git a/ceph_deploy/tests/test_cli_new.py b/ceph_deploy/tests/test_cli_new.py index 182729e..4e926ad 100644 --- a/ceph_deploy/tests/test_cli_new.py +++ b/ceph_deploy/tests/test_cli_new.py @@ -22,9 +22,10 @@ def test_help(tmpdir, cli): def test_write_global_conf_section(tmpdir, cli): - with patch('ceph_deploy.new.socket.getaddrinfo', fake_getaddrinfo): - with directory(str(tmpdir)): - main(args=['new', 'host1']) + with patch('ceph_deploy.new.socket.gethostbyname'): + with patch('ceph_deploy.new.socket.getaddrinfo', fake_getaddrinfo): + with directory(str(tmpdir)): + main(args=['new', 'host1']) with tmpdir.join('ceph.conf').open() as f: cfg = conf.parse(f) assert cfg.sections() == ['global'] @@ -35,12 +36,13 @@ def pytest_funcarg__newcfg(request): cli = request.getfuncargvalue('cli') def new(*args): - with patch('ceph_deploy.new.socket.getaddrinfo', fake_getaddrinfo): - with directory(str(tmpdir)): - main( args=['new'] + list(args)) - with tmpdir.join('ceph.conf').open() as f: - cfg = conf.parse(f) - return cfg + with patch('ceph_deploy.new.socket.gethostbyname'): + with patch('ceph_deploy.new.socket.getaddrinfo', fake_getaddrinfo): + with directory(str(tmpdir)): + main( args=['new'] + list(args)) + with tmpdir.join('ceph.conf').open() as f: + cfg = conf.parse(f) + return cfg return new