From bfd82261422f304bdc84617a485db05fa2efefeb Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 30 Jun 2014 17:23:20 -0600 Subject: [PATCH] Run unit tests offline Signed-off-by: Zack Cerza --- teuthology/test/test_repo_utils.py | 60 ++++++++++++++++++------------ 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/teuthology/test/test_repo_utils.py b/teuthology/test/test_repo_utils.py index 9152b125b6315..e03831292ca0c 100644 --- a/teuthology/test/test_repo_utils.py +++ b/teuthology/test/test_repo_utils.py @@ -2,58 +2,70 @@ import logging import os.path from pytest import raises import shutil +import subprocess from .. import repo_utils repo_utils.log.setLevel(logging.WARNING) class TestRepoUtils(object): - empty_repo = 'https://github.com/ceph/empty' - local_dir = '/tmp/empty' + src_path = '/tmp/empty_src' + repo_url = 'file://' + src_path + dest_path = '/tmp/empty_dest' def setup(self): - assert not os.path.exists(self.local_dir) + assert not os.path.exists(self.dest_path) + proc = subprocess.Popen( + ('git', 'init', self.src_path), + ) + assert proc.wait() == 0 + proc = subprocess.Popen( + ('git', 'commit', '--allow-empty', '--allow-empty-message', + '--no-edit'), + cwd=self.src_path, + ) + assert proc.wait() == 0 def teardown(self): - shutil.rmtree(self.local_dir, ignore_errors=True) + shutil.rmtree(self.dest_path, ignore_errors=True) def test_existing_branch(self): - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) + assert os.path.exists(self.dest_path) def test_non_existing_branch(self): with raises(repo_utils.BranchNotFoundError): - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'blah') - assert not os.path.exists(self.local_dir) + assert not os.path.exists(self.dest_path) def test_multiple_calls_same_branch(self): - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + assert os.path.exists(self.dest_path) + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + assert os.path.exists(self.dest_path) + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) + assert os.path.exists(self.dest_path) def test_multiple_calls_different_branches(self): with raises(repo_utils.BranchNotFoundError): - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'blah1') - assert not os.path.exists(self.local_dir) - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + assert not os.path.exists(self.dest_path) + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + assert os.path.exists(self.dest_path) + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) + assert os.path.exists(self.dest_path) with raises(repo_utils.BranchNotFoundError): - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'blah2') - assert not os.path.exists(self.local_dir) - repo_utils.enforce_repo_state(self.empty_repo, self.local_dir, + assert not os.path.exists(self.dest_path) + repo_utils.enforce_repo_state(self.repo_url, self.dest_path, 'master') - assert os.path.exists(self.local_dir) + assert os.path.exists(self.dest_path) -- 2.39.5