diff options
-rw-r--r-- | morphlib/localartifactcache.py | 8 | ||||
-rw-r--r-- | morphlib/localartifactcache_tests.py | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/morphlib/localartifactcache.py b/morphlib/localartifactcache.py index 51ccb4f6..893359d8 100644 --- a/morphlib/localartifactcache.py +++ b/morphlib/localartifactcache.py @@ -25,7 +25,7 @@ class LocalArtifactCache(object): self.cachedir = cachedir def put(self, artifact): - filename = self._artifact_filename(artifact) + filename = self.artifact_filename(artifact) return morphlib.savefile.SaveFile(filename, mode='w') def put_artifact_metadata(self, artifact, name): @@ -37,7 +37,7 @@ class LocalArtifactCache(object): return morphlib.savefile.SaveFile(filename, mode='w') def has(self, artifact): - filename = self._artifact_filename(artifact) + filename = self.artifact_filename(artifact) return os.path.exists(filename) def has_artifact_metadata(self, artifact, name): @@ -49,7 +49,7 @@ class LocalArtifactCache(object): return os.path.exists(filename) def get(self, artifact): - filename = self._artifact_filename(artifact) + filename = self.artifact_filename(artifact) return open(filename) def get_artifact_metadata(self, artifact, name): @@ -60,7 +60,7 @@ class LocalArtifactCache(object): filename = self._source_metadata_filename(source, cachekey, name) return open(filename) - def _artifact_filename(self, artifact): + def artifact_filename(self, artifact): basename = artifact.basename() return os.path.join(self.cachedir, basename) diff --git a/morphlib/localartifactcache_tests.py b/morphlib/localartifactcache_tests.py index c3deb9dc..8e25e5c9 100644 --- a/morphlib/localartifactcache_tests.py +++ b/morphlib/localartifactcache_tests.py @@ -15,6 +15,7 @@ import unittest +import os import morphlib @@ -52,6 +53,14 @@ class LocalArtifactCacheTests(unittest.TestCase): def tearDown(self): self.tempdir.remove() + def test_artifact_filename(self): + cache = morphlib.localartifactcache.LocalArtifactCache( + self.tempdir.dirname) + filename = cache.artifact_filename(self.devel_artifact) + expected_name = os.path.join(self.tempdir.dirname, + self.devel_artifact.basename()) + self.assertEqual(filename, expected_name) + def test_put_artifacts_and_check_whether_the_cache_has_them(self): cache = morphlib.localartifactcache.LocalArtifactCache( self.tempdir.dirname) |