diff options
author | Lars Wirzenius <liw@gytha> | 2008-04-20 17:54:48 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@gytha> | 2008-04-20 17:54:48 +0300 |
commit | ce82a16369689a43dad7304836fdfc0649a5a223 (patch) | |
tree | f5176a1083f2f85db88e2d2a98d8b33b185d0599 /obnam | |
parent | e05007300f96f8f477df7f19c79c89e380672e82 (diff) | |
download | obnam-ce82a16369689a43dad7304836fdfc0649a5a223.tar.gz |
Implemented Application.get_dir_in_previous_generation.
Diffstat (limited to 'obnam')
-rw-r--r-- | obnam/app.py | 5 | ||||
-rw-r--r-- | obnam/appTests.py | 27 |
2 files changed, 31 insertions, 1 deletions
diff --git a/obnam/app.py b/obnam/app.py index 926ab69c..a832a841 100644 --- a/obnam/app.py +++ b/obnam/app.py @@ -276,6 +276,11 @@ class Application: def _make_absolute(self, basename, relatives): return [os.path.join(basename, name) for name in relatives] + def get_dir_in_previous_generation(self, dirname): + """Return directory in previous generation, or None.""" + gen = self.get_previous_generation() + return self.get_store().lookup_dir(gen, dirname) + def backup_one_dir(self, dirname, subdirs, filenames): """Back up non-recursively one directory. diff --git a/obnam/appTests.py b/obnam/appTests.py index 4019dd92..bce9bddc 100644 --- a/obnam/appTests.py +++ b/obnam/appTests.py @@ -243,7 +243,6 @@ class ApplicationUnchangedFileGroupTests(unittest.TestCase): stat=self.mock_stat)) - class ApplicationUnchangedDirTests(unittest.TestCase): def setUp(self): @@ -394,6 +393,32 @@ class ApplicationFindUnchangedFilegroupsTests(unittest.TestCase): self.failUnlessEqual(self.find(self.groups, self.names), []) +class ApplicationGetDirInPreviousGenerationTests(unittest.TestCase): + + class MockStore: + + def __init__(self): + self.dict = { + "pink": obnam.obj.DirObject(id="id", name="pink"), + } + + def lookup_dir(self, gen, pathname): + return self.dict.get(pathname, None) + + def setUp(self): + context = obnam.context.Context() + self.app = obnam.Application(context) + self.app._store = self.MockStore() + + def testReturnsNoneIfDirectoryDidNotExist(self): + self.failUnlessEqual(self.app.get_dir_in_previous_generation("xx"), + None) + + def testReturnsDirObjectIfDirectoryDidExist(self): + dir = self.app.get_dir_in_previous_generation("pink") + self.failUnlessEqual(dir.get_name(), "pink") + + class ApplicationFindFileByNameTests(unittest.TestCase): def setUp(self): |