Mikhail Korobov avatar Mikhail Korobov committed 1a10d52

Basic tests for push and undeploy commands

Comments (0)

Files changed (3)


     if 'test' not in args:
-def undeploy():
+def undeploy(confirm=True):
     """ Shuts site down. This command doesn't clean everything, e.g.
     user data (database, backups) is preserved. """
-    if not console.confirm("Do you wish to undeploy host %s?" % env.hosts[0], default=False):
-        abort("Aborting.")
+    if confirm:
+        message = "Do you wish to undeploy host %s?" % env.hosts[0]
+        if not console.confirm(message, default=False):
+            abort("Aborting.")
     def wipe_web():
         run('invoke-rc.d apache2 reload')
-    run('rm -rf %s' % env.conf['SRC_DIR'])
+    run('rm -rf %s' % env.conf.SRC_DIR)
     for folder in ['bin', 'include', 'lib', 'src']:
-        run('rm -rf %s' % env.conf['ENV_DIR'] + '/' + folder)
+        run('rm -rf %s' % env.conf.ENV_DIR + '/' + folder)


     PROJECT_PATH = 'src',
     LOCAL_CONFIG = 'local_settings.py',
     REMOTE_CONFIG_TEMPLATE = 'staging_settings.py',
     PIP_REQUIREMENTS = 'requirements.txt',
+    PIP_REQUIREMENTS_ACTIVE = 'requirements.txt',
     CONFIG_TEMPLATES_PATHS = ['hosting/staging', 'hosting'],


 from __future__ import absolute_import
 import os
+import urllib2
 from fab_deploy.utils import run_as
 from fabric.api import *
 from fabtest import fab, vbox_urlopen
-from fab_deploy.deploy import deploy_project
+from fab_deploy.deploy import deploy_project, push, undeploy, full_deploy
 from fab_deploy.mysql import mysql_create_db
 from fab_deploy.apache import (apache_make_config, apache_make_wsgi,
                                apache_restart, apache_install)
     project = 'test_project2'
     def test_deploy(self):
+        url = 'http://foo.example.com/instance/'
-        self.assertResponse('http://foo.example.com/instance/', 'foo')
+        self.assertResponse(url, 'foo')
+        # just check that blank push doesn't break anything
+        # TODO: proper push tests
+        fab(push, 'pip_update', 'syncdb')
+        self.assertResponse(url, 'foo')
+        # check that updeploy disables the site
+        # TODO: more undeploy tests
+        fab(undeploy, confirm=False)
+        self.assertRaises(Exception, vbox_urlopen, url)
+        # deploying project again should be possible
+        fab(deploy_project)
+        self.assertResponse(url, 'foo')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.