]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
This is absolutely TERRIBLE
authorAlfredo Deza <alfredo.deza@inktank.com>
Wed, 27 Aug 2014 17:03:13 +0000 (13:03 -0400)
committerAlfredo Deza <alfredo.deza@inktank.com>
Wed, 27 Aug 2014 20:41:13 +0000 (16:41 -0400)
we have to now patch like mad people all these methods. These
old tests should burn in the fire of the parent suns of the galaxy.

Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/tests/test_cli_mon.py
ceph_deploy/tests/test_cli_new.py

index 80778885c152e765aa3813312a894df4cae4237b..1ea80d26d5c62920e5365f87a5498c1cf76e514e 100644 (file)
@@ -45,6 +45,17 @@ def test_bad_no_mon(tmpdir, cli):
     assert err.value.status == 2
 
 
+from mock import Mock, patch
+
+
+def make_fake_connection(platform_information=None):
+    get_connection = Mock()
+    get_connection.return_value = get_connection
+    get_connection.remote_module.platform_information = Mock(
+        return_value=platform_information)
+    return get_connection
+
+
 def test_simple(tmpdir, capsys):
     with tmpdir.join('ceph.conf').open('w') as f:
         f.write("""\
@@ -67,18 +78,21 @@ mon initial members = host1
         secret = get_monitor_secret()
         assert secret == MON_SECRET
 
+    fake_ip_addresses = lambda x: ['10.0.0.1']
     try:
-        with mock.patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x, subnet: '10.0.0.1'):
-            with mock.patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
-                with directory(str(tmpdir)):
-                    main(
-                        args=['-v', 'new', 'host1'],
-                        namespace=ns,
-                        )
-                    main(
-                        args=['-v', 'mon', 'create', 'host1'],
-                        namespace=ns,
-                        )
+        with patch('ceph_deploy.new.net.ip_addresses', fake_ip_addresses):
+            with mock.patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x: '10.0.0.1'):
+                with mock.patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
+                    with mock.patch('ceph_deploy.new.hosts'):
+                        with directory(str(tmpdir)):
+                            main(
+                                args=['-v', 'new', '--no-ssh-copykey', '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()
index 0251f425ec1d3f4cd2ffeea5686b785103f86a7d..478bee9d914678053c21245c341a125d765ad388 100644 (file)
@@ -20,10 +20,14 @@ def test_help(tmpdir, cli):
 
 
 def test_write_global_conf_section(tmpdir, cli):
-    with patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x, subnet: '10.0.0.1'):
-        with patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
-            with directory(str(tmpdir)):
-                main(args=['new', 'host1'])
+    fake_ip_addresses = lambda x: ['10.0.0.1']
+
+    with patch('ceph_deploy.new.hosts'):
+        with patch('ceph_deploy.new.net.ip_addresses', fake_ip_addresses):
+            with patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x: '10.0.0.1'):
+                with patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
+                    with directory(str(tmpdir)):
+                        main(args=['new', 'host1'])
     with tmpdir.join('ceph.conf').open() as f:
         cfg = conf.ceph.parse(f)
     assert cfg.sections() == ['global']
@@ -31,15 +35,18 @@ def test_write_global_conf_section(tmpdir, cli):
 
 def pytest_funcarg__newcfg(request):
     tmpdir = request.getfuncargvalue('tmpdir')
+    fake_ip_addresses = lambda x: ['10.0.0.1']
 
     def new(*args):
-        with patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x, subnet: '10.0.0.1'):
-            with patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
-                with directory(str(tmpdir)):
-                    main(args=['new'] + list(args))
-                    with tmpdir.join('ceph.conf').open() as f:
-                        cfg = conf.ceph.parse(f)
-                    return cfg
+        with patch('ceph_deploy.new.net.ip_addresses', fake_ip_addresses):
+            with patch('ceph_deploy.new.hosts'):
+                with patch('ceph_deploy.new.net.get_nonlocal_ip', lambda x: '10.0.0.1'):
+                    with patch('ceph_deploy.new.arg_validators.Hostname', lambda: lambda x: x):
+                        with directory(str(tmpdir)):
+                            main(args=['new'] + list(args))
+                            with tmpdir.join('ceph.conf').open() as f:
+                                cfg = conf.ceph.parse(f)
+                            return cfg
     return new