More tests, more bug fixes
[doneit] / tests / test_cache_backend.py
1 import os
2
3 import test_backend
4
5 import sys
6 sys.path.append("../src")
7
8 import file_backend
9 import cache_backend
10
11
12 class TestCacheBackend(object):
13
14         def test_projects(self):
15                 fileBackend = file_backend.FileBackend(os.tmpnam())
16                 backend = cache_backend.LazyCacheBackend(fileBackend)
17                 test_backend.exercise_projects(backend)
18
19                 # Confirm cache matches actual
20                 fileProjects = list(fileBackend.get_projects())
21                 fileProjects.sort()
22                 cacheProjects = list(backend.get_projects())
23                 cacheProjects.sort()
24                 assert fileProjects == cacheProjects
25
26         def test_locations(self):
27                 fileBackend = file_backend.FileBackend(os.tmpnam())
28                 backend = cache_backend.LazyCacheBackend(fileBackend)
29                 test_backend.exercise_locations(backend)
30
31                 # Confirm cache matches actual
32                 fileLocations = list(fileBackend.get_locations())
33                 fileLocations.sort()
34                 cacheLocations = list(backend.get_locations())
35                 cacheLocations.sort()
36                 assert fileLocations == cacheLocations