summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-18 16:15:47 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-07-18 16:17:39 +0100
commitd400ccc735a6282680529f321614062fcef50f23 (patch)
tree4239e60b9762777d55092d2edf4fb76ee4ccf676 /morphlib
parent82162907439d79afa5a8063d66426288ccfb21dc (diff)
downloadmorph-d400ccc735a6282680529f321614062fcef50f23.tar.gz
Add missing empty lines, for clarity
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/morphologyfactory.py5
-rw-r--r--morphlib/morphologyfactory_tests.py13
2 files changed, 18 insertions, 0 deletions
diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py
index de9e03e5..5a049d04 100644
--- a/morphlib/morphologyfactory.py
+++ b/morphlib/morphologyfactory.py
@@ -18,22 +18,27 @@
import morphlib
import cliapp
+
class MorphologyFactoryError(cliapp.AppException):
pass
+
class AutodetectError(MorphologyFactoryError):
def __init__(self, repo_name, ref):
MorphologyFactoryError.__init__(self,
"Failed to determine the build system of repo %s at "
"ref %s" % (repo_name, ref))
+
class NotcachedError(MorphologyFactoryError):
def __init__(self, repo_name):
MorphologyFactoryError.__init__(self,
"Repository %s is not cached locally and there is no "
"remote cache specified" % repo_name)
+
class MorphologyFactory(object):
+
'''An way of creating morphologies which will provide a default'''
def __init__(self, local_repo_cache, remote_repo_cache=None):
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py
index 0cd9e4b1..11d53a19 100644
--- a/morphlib/morphologyfactory_tests.py
+++ b/morphlib/morphologyfactory_tests.py
@@ -22,7 +22,9 @@ from morphlib.morphologyfactory import (MorphologyFactory,
NotcachedError)
from morphlib.remoterepocache import CatFileError
+
class FakeRemoteRepoCache(object):
+
def cat_file(self, reponame, sha1, filename):
if filename.endswith('.morph'):
return '''{
@@ -32,7 +34,9 @@ class FakeRemoteRepoCache(object):
}'''
return 'text'
+
class FakeLocalRepo(object):
+
def cat(self, sha1, filename):
if filename.endswith('.morph'):
return '''{
@@ -42,15 +46,21 @@ class FakeLocalRepo(object):
}'''
return 'text'
+
class FakeLocalRepoCache(object):
+
def __init__(self, lr):
self.lr = lr
+
def has_repo(self, reponame):
return True
+
def get_repo(self, reponame):
return self.lr
+
class MorphologyFactoryTests(unittest.TestCase):
+
def setUp(self):
self.lr = FakeLocalRepo()
self.lrc = FakeLocalRepoCache(self.lr)
@@ -60,12 +70,15 @@ class MorphologyFactoryTests(unittest.TestCase):
def nolocalfile(self, *args):
raise IOError('File not found')
+
def noremotefile(self, *args):
raise CatFileError('reponame', 'ref', 'filename')
+
def nolocalmorph(self, *args):
if args[-1].endswith('.morph'):
raise IOError('File not found')
return 'text'
+
def noremotemorph(self, *args):
if args[-1].endswith('.morph'):
raise CatFileError('reponame', 'ref', 'filename')