Commits

Mikhail Korobov committed a85f3e5

More and better tests, coverage is still as low as 54%.

Comments (0)

Files changed (2)

fab_deploy_tests/runtests.py

         sys.exit(1)
 
     FabDeployTest.vm_name = sys.argv[1]
+    suites = {
+        'fast': get_suite([BasicTest, SshTest, FastPrepareServerTest, MysqlTest]),
+        'slow': get_suite([PrepareServerTest])
+    }
 
-    suites = {
-        'fast': get_suite([BasicTest, MysqlTest, FastSystemTest])
-    }
     suites['all'] = unittest.TestSuite(suites.values())
 
     suite_name = sys.argv[2]

fab_deploy_tests/tests/system_tests.py

 from __future__ import absolute_import
+from fabric.api import run,env
 from fabtest import fab
 
-from fab_deploy.system import prepare_server
+from fab_deploy.utils import run_as
 
+from fab_deploy.system import prepare_server, ssh_add_key
+from fab_deploy.apache import apache_install
+from fab_deploy.nginx import nginx_install
+
+from fab_deploy_tests.utils import setup_ssh, public_key_path
 from .base import FabDeployTest
-from fab_deploy_tests.utils import setup_ssh
 
-class FastSystemTest(FabDeployTest):
+@run_as('root')
+def setup_root_ssh():
+    ssh_add_key(public_key_path())
+
+@run_as('root')
+def whoami():
+    return run('whoami')
+
+class SshTest(FabDeployTest):
     def test_python(self):
         self.assertPackageInstalled('python-minimal')
 
             self.assertUserIs('foo')
         fab(command)
 
-class SystemTest(FabDeployTest):
+    def test_add_ssh_key(self):
+        fab(setup_root_ssh)
+        env.password=None # should use ssh key
+        self.assertEqual(fab(whoami)[0], 'root')
+
+
+class PrepareServerTest(FabDeployTest):
     def test_prepare_server_ok(self):
         fab(prepare_server)
         self.assertPackageInstalled('memcached')
         self.assertPackageInstalled('python')
 
+        fab(apache_install)
+        fab(nginx_install)
+        self.assertPackageInstalled('nginx')
+        self.assertPackageInstalled('apache2')
+
+
+class FastPrepareServerTest(PrepareServerTest):
+    snapshot = 'fabtest-prepared-server'
+