Commits

Mikhail Korobov committed efaed7d

tests are updated for fabtest==0.1

Comments (0)

Files changed (9)

fab_deploy_tests/preparevm.py

 from fab_deploy.nginx import nginx_install
 from fab_deploy.mysql import mysql_install
 
-def activate_snapshot(box, name):
-    box.stop()
-    box.snapshot('restore', name)
-    box.start()
-
 def deep_prepare(name):
     """ Deep VM preparation for test speedups.
     Should only be run if all related tests are passed.
     env.hosts = ['foo@127.0.0.1:2222']
     env.password = '123'
     env.disable_known_hosts = True
-    env.conf = {'DB_PASSWORD': '123'}
+    env.conf = {'DB_PASSWORD': '123', 'DB_USER': 'root'}
     env.key_filename = private_key_path()
     update_env()
 
     box = VirtualBox(name)
 
     if not box.snapshot_exists('fabtest-prepared-server'):
-        activate_snapshot(box, 'fabtest-initial')
+        box.snapshot_restore('fabtest-initial')
         setup_sudo()
         setup_ssh()
         fab(prepare_server)
         fab(apache_install)
         fab(nginx_install)
         fab(mysql_install)
-        box.snapshot('take', 'fabtest-prepared-server')
+        box.snapshot_take('fabtest-prepared-server')
 
     box.stop()
 

fab_deploy_tests/runtests.py

         unittest.TextTestRunner(verbosity=2).run(suites[suite_name])
     else:
         sys.argv = [sys.argv[0]] + sys.argv[2:]
-        unittest.main()
+        unittest.main(verbosity=2)

fab_deploy_tests/tests/crontab.py

     snapshot = 'fabtest-prepared-server'
 
     def current(self):
-        return fab(_get_current)[0]
+        return fab(_get_current)
 
     def add(self, content, marker):
-        return fab(crontab_add, content, marker)[0]
+        return fab(crontab_add, content, marker)
 
     def remove(self, marker):
-        return fab(crontab_remove, marker)[0]
+        return fab(crontab_remove, marker)
 
     def update(self, content, marker):
-        return fab(crontab_update, content, marker)[0]
+        return fab(crontab_update, content, marker)
 
     def test_crontab(self):
         line1 = '@reboot echo 123'

fab_deploy_tests/tests/deploy.py

     def cat():
         with(hide('stdout')):
             return run('cat '+remote_file)
-    return fab(cat)[0]
+    return fab(cat)
 
 def get_ports():
     @run_as('root')
     def ports():
         return run('netstat -A inet -lnp')
-    return fab(ports)[0]
+    return fab(ports)
 
 def is_local_port_binded(port):
     port_string = '127.0.0.1:%s' % port
 
     def assertCommandAvailable(self, command):
         result = fab(command_is_available, command)
-        self.assertTrue(result[0])
+        self.assertTrue(result)
 
     def assertCommandNotAvailable(self, command):
         result = fab(command_is_available, command)
-        self.assertFalse(result[0])
+        self.assertFalse(result)
 
     def assertCommandFails(self, command):
         self.assertRaises(FabricAbortException, fab,

fab_deploy_tests/tests/mysql.py

 from .base import FabDeployTest
 
 def mysql_is_installed():
-    return fab(_mysql_is_installed)[0]
+    return fab(_mysql_is_installed)
 
 def database_exists(db_name):
-    databases = fab(mysql_execute, 'show databases;', 'root')[0].splitlines()
+    databases = fab(mysql_execute, 'show databases;', 'root').splitlines()
     return db_name in databases
 
 class MysqlTest(FabDeployTest):
         fab(mysql_create_user)
 
         # this will fail if permissions are not set correctly
-        output = fab(mysql_execute, 'use new_database; create table baz (id int); show tables;')[0]
+        output = fab(mysql_execute, 'use new_database; create table baz (id int); show tables;')
         tables = output.splitlines()[1:]
         self.assertEqual(tables[0], 'baz')
 

fab_deploy_tests/tests/system_tests.py

     def test_add_ssh_key(self):
         fab(setup_root_ssh)
         env.password = None # should use ssh key
-        self.assertEqual(fab(whoami)[0], 'root')
+        self.assertEqual(fab(whoami), 'root')
 
 
 class PrepareServerTest(FabDeployTest):

fab_deploy_tests/tests/utils_tests.py

 
 class BasicTest(FabDeployTest):
     def test_run_as(self):
-        user = fab(whoami)[0]
+        user = fab(whoami)
         self.assertEqual(user, 'root')
 
     def test_create_sudo_linux_account(self):
         def whoami():
             return run('whoami')
 
-        user = fab(whoami)[0]
+        user = fab(whoami)
         self.assertEqual(user, 'testsudo')
 
         @run_as('testsudo')

fab_deploy_tests/utils.py

         regexp = "^%s$" % name
         output = run('aptitude -q -F "%%c" search %s' % regexp)
         return output.splitlines()[-1]
-    return fab(command)[0]
+    return fab(command)
 
 def setup_ssh():
     fab(create_linux_account, public_key_path())
 django-fab-deploy == 0.7.1
 jinja2
-fabric >= 1.0.0
+fabric >= 1.4.0