def test_start(self): """ start - test to ensure that ``start`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.start(None) except GitDeployError: self.assertTrue(False)
def test_revert(self): """ revert - test to ensure that ``revert`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.revert(namedtuple('o', 'force')(False)) except GitDeployError: self.assertTrue(False)
def test_log_deploys(self): """ log_deploys - test to ensure that ``log_deploys`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.log_deploys(namedtuple('o', 'count')(1)) except GitDeployError: self.assertTrue(False)
def test_diff(self): """ diff - test to ensure that ``diff`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.diff(None) except GitDeployError: self.assertTrue(False)
def test_sync(self): """ sync - test to ensure that ``sync`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.start(None) git_deploy_obj.sync(None) # TODO - check tag and deploy file except GitDeployError: self.assertTrue(False)
def test_abort(self): """ abort - test to ensure that ``abort`` method functions without exception """ git_deploy_obj = GitDeploy() try: git_deploy_obj.start(None) git_deploy_obj.abort(None) # TODO - check lock file & commit except GitDeployError: self.assertTrue(False)
def test_deploy_in_progress(self): """ deploy_in_progress - test to ensure that when the ``start`` method is called when a deployment is in progress GitDeploy exits with error """ git_deploy_obj = GitDeploy() # TODO - ensure that the repo is "fresh" # Call ``start`` twice try: git_deploy_obj.start(None) git_deploy_obj.start(None) except GitDeployError as e: if not e.message == exit_codes[2]: self.assertTrue(False) return self.assertTrue(False)
def test_singleton(self): s1 = GitDeploy() s2 = GitDeploy() self.assertEquals(s1, s2)
def test_conf_deploy_root(self): s = GitDeploy() self.assertIn('deploy_root', s.config)
def test_conf_repo_name(self): s = GitDeploy() self.assertIn('repo_name', s.config)
def test_conf_top_dir(self): s = GitDeploy() self.assertIn('hook_dir', s.config)
import tempfile from collections import namedtuple from git_deploy.config import log from git_deploy.git_deploy import GitDeploy, GitMethods, GitDeployError, \ exit_codes from dulwich.repo import Repo from os import mkdir, chdir from os.path import exists from shutil import rmtree from git_deploy.config import configure # Create the initial singleton config = configure() GitDeploy(path=config['deploy.test_repo'], client_path=config['deploy.test_repo']) def setup_deco(test_method): """ Performs setup and teardown calls for all tests to decouple the state if the repo from this testing module. """ def setup_wrap(self): init_tmp_repo() try: test_method(self) finally: teardown_tmp_repo() setup_wrap.__name__ = test_method.__name__