From: Zack Cerza Date: Mon, 30 Jun 2014 23:23:20 +0000 (-0600) Subject: Run unit tests offline X-Git-Tag: 1.1.0~1359^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=bfd82261422f304bdc84617a485db05fa2efefeb;p=teuthology.git Run unit tests offline Signed-off-by: Zack Cerza --- diff --git a/teuthology/test/test_repo_utils.py b/teuthology/test/test_repo_utils.py index 9152b125b6..e03831292c 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)