Commits

Mikhail Korobov committed 52e85ca

Tests for custom project layouts, git uploads and non-mysql servers.

Comments (0)

Files changed (3)

fab_deploy_tests/git_ssh.sh

+#!/bin/sh
+exec ssh -o NoHostAuthenticationForLocalhost=yes -i ../keys/id_rsa "$@"

fab_deploy_tests/runtests.py

 #!/usr/bin/env python
 import sys
-import os.path
+import os
 import unittest
 from unittest import TestSuite, TestLoader
 
 path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
 sys.path.insert(0, path)
 
+# setup git ssh environment
+os.environ['GIT_SSH'] = os.path.join(path, 'fab_deploy_tests', 'git_ssh.sh')
+
 from fab_deploy_tests.tests import *
 
 def load(cases):
     common_tests = load([BasicTest, SshTest, MysqlTest, CrontabTest])
     suites = {
         'fast': TestSuite(common_tests + load([FastPrepareServerTest, ApacheSetupTest])),
-        'slow': TestSuite(load([DeployTest])),
+        'slow': TestSuite(load([DeployTest, CustomLayoutDeployTest])),
         'prepare': TestSuite(common_tests + load([PrepareServerTest])),
     }
     suites['all'] = TestSuite([suites['fast'], suites['slow']])

fab_deploy_tests/tests/deploy.py

 from fabtest import fab, vbox_urlopen
 from fab_deploy.deploy import deploy_project
 from fab_deploy.mysql import mysql_create_db
-from fab_deploy.apache import apache_make_config, apache_make_wsgi, apache_restart, apache_install
+from fab_deploy.apache import (apache_make_config, apache_make_wsgi,
+                               apache_restart, apache_install)
 from .base import FabDeployTest
 from ..test_project.fabfile import foo_site, bar_site
+from ..test_project2.fabfile import foo_site as foo_site2
 
 def get_file_content(remote_file):
     @run_as('root')
 
 class FabDeployProjectTest(FabDeployTest):
     snapshot = 'fabtest-prepared-server'
+    project = 'test_project'
+
+    def assertResponse(self, url, data):
+        self.assertEqual(vbox_urlopen(url).read(), data)
 
     def setup_conf(self):
         self.cwd = os.getcwd()
-        os.chdir('test_project')
+        os.chdir(self.project)
         fab(foo_site)
 
     def tearDown(self):
 
 class DeployTest(FabDeployProjectTest):
 
-    def assertResponse(self, url, data):
-        self.assertEqual(vbox_urlopen(url).read(), data)
-
     def test_deploy(self):
         # deploy first site
         fab(foo_site)
         self.assertResponse('http://bar.example.com/instance/', 'bar')
         # first site is still available
         self.assertResponse('http://foo.example.com/instance/', 'foo')
+
+
+class CustomLayoutDeployTest(FabDeployProjectTest):
+    project = 'test_project2'
+
+    def test_deploy(self):
+        fab(foo_site2)
+        fab(deploy_project)
+        self.assertResponse('http://foo.example.com/instance/', 'foo')