]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
Move exception into a new exceptions module
authorZack Cerza <zack.cerza@inktank.com>
Wed, 6 Aug 2014 21:11:01 +0000 (15:11 -0600)
committerZack Cerza <zack.cerza@inktank.com>
Thu, 7 Aug 2014 17:13:42 +0000 (11:13 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/exceptions.py [new file with mode: 0644]
teuthology/repo_utils.py
teuthology/suite.py
teuthology/test/test_repo_utils.py
teuthology/worker.py

diff --git a/teuthology/exceptions.py b/teuthology/exceptions.py
new file mode 100644 (file)
index 0000000..4ace8b4
--- /dev/null
@@ -0,0 +1,13 @@
+
+class BranchNotFoundError(ValueError):
+    def __init__(self, branch, repo=None):
+        self.branch = branch
+        self.repo = repo
+
+    def __str__(self):
+        if self.repo:
+            repo_str = " in repo: %s" % self.repo
+        else:
+            repo_str = ""
+        return "Branch '{branch}' not found{repo_str}!".format(
+            branch=self.branch, repo_str=repo_str)
index 23182f0037456771e3c2d7b05333c4343df7b8cb..40d45530d1f130ba5658aa988a032f1ce96a5782 100644 (file)
@@ -6,6 +6,7 @@ import subprocess
 import time
 
 from .config import config
+from .exceptions import BranchNotFoundError
 
 log = logging.getLogger(__name__)
 
@@ -136,20 +137,6 @@ def reset_repo(repo_url, dest_path, branch):
         raise BranchNotFoundError(branch, repo_url)
 
 
-class BranchNotFoundError(ValueError):
-    def __init__(self, branch, repo=None):
-        self.branch = branch
-        self.repo = repo
-
-    def __str__(self):
-        if self.repo:
-            repo_str = " in repo: %s" % self.repo
-        else:
-            repo_str = ""
-        return "Branch '{branch}' not found{repo_str}!".format(
-            branch=self.branch, repo_str=repo_str)
-
-
 def validate_branch(branch):
     if ' ' in branch:
         raise ValueError("Illegal branch name: '%s'" % branch)
index 365450dc5704ab413a89ae2a76a23bafaa5d4c87..fe2bd241888b3b8e4d5b58c35a1589125d0ee9d2 100644 (file)
@@ -19,7 +19,8 @@ from tempfile import NamedTemporaryFile
 import teuthology
 from . import lock
 from .config import config, JobConfig
-from .repo_utils import enforce_repo_state, BranchNotFoundError
+from .repo_utils import enforce_repo_state
+from .exceptions import BranchNotFoundError
 
 log = logging.getLogger(__name__)
 
index d85fed8dbc1f963c10726a723bcaae91afd4bfca..75def4ced554fd5ee951c4c5bee589e50b8be60f 100644 (file)
@@ -5,6 +5,7 @@ from pytest import raises
 import shutil
 import subprocess
 
+from ..exceptions import BranchNotFoundError
 from .. import repo_utils
 from .. import parallel
 repo_utils.log.setLevel(logging.WARNING)
@@ -61,7 +62,7 @@ class TestRepoUtils(object):
         assert os.path.exists(self.dest_path)
 
     def test_clone_repo_non_existing_branch(self):
-        with raises(repo_utils.BranchNotFoundError):
+        with raises(BranchNotFoundError):
             repo_utils.clone_repo(self.repo_url, self.dest_path, 'nobranch')
         assert not os.path.exists(self.dest_path)
 
@@ -86,7 +87,7 @@ class TestRepoUtils(object):
 
     def test_fetch_branch_fake_branch(self):
         repo_utils.clone_repo(self.repo_url, self.dest_path, 'master')
-        with raises(repo_utils.BranchNotFoundError):
+        with raises(BranchNotFoundError):
             repo_utils.fetch_branch(self.dest_path, 'nobranch')
 
     def test_enforce_existing_branch(self):
@@ -95,7 +96,7 @@ class TestRepoUtils(object):
         assert os.path.exists(self.dest_path)
 
     def test_enforce_non_existing_branch(self):
-        with raises(repo_utils.BranchNotFoundError):
+        with raises(BranchNotFoundError):
             repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
                                           'blah')
         assert not os.path.exists(self.dest_path)
@@ -112,7 +113,7 @@ class TestRepoUtils(object):
         assert os.path.exists(self.dest_path)
 
     def test_enforce_multiple_calls_different_branches(self):
-        with raises(repo_utils.BranchNotFoundError):
+        with raises(BranchNotFoundError):
             repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
                                           'blah1')
         assert not os.path.exists(self.dest_path)
@@ -122,7 +123,7 @@ class TestRepoUtils(object):
         repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
                                       'master')
         assert os.path.exists(self.dest_path)
-        with raises(repo_utils.BranchNotFoundError):
+        with raises(BranchNotFoundError):
             repo_utils.enforce_repo_state(self.repo_url, self.dest_path,
                                           'blah2')
         assert not os.path.exists(self.dest_path)
@@ -161,7 +162,7 @@ class TestRepoUtils(object):
                             branch)
                     p.spawn(
                         raises,
-                        repo_utils.BranchNotFoundError,
+                        BranchNotFoundError,
                         func,
                     )
             for result in p:
index 24a6b6efab2befab7f9a76517d2df93eabb44d57..01efab371f5eead0065a3934617365c491bf8e7e 100644 (file)
@@ -13,9 +13,9 @@ from . import beanstalk
 from . import report
 from . import safepath
 from .config import config as teuth_config
+from .exceptions import BranchNotFoundError
 from .kill import kill_job
 from .misc import read_config
-from .repo_utils import BranchNotFoundError
 from .repo_utils import fetch_qa_suite, fetch_teuthology_branch
 
 log = logging.getLogger(__name__)