61
61
# check we hit without re-reading
62
62
self.assertEquals(hc.get_sha1('foo'),
63
63
'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d')
64
##self.assertEquals(hc.miss_count, 1)
65
##self.assertEquals(hc.hit_count, 1)
64
self.assertEquals(hc.miss_count, 1)
65
self.assertEquals(hc.hit_count, 1)
67
67
# check again without re-reading
68
68
self.assertEquals(hc.get_sha1('foo'),
69
69
'aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d')
70
##self.assertEquals(hc.miss_count, 1)
71
##self.assertEquals(hc.hit_count, 2)
70
self.assertEquals(hc.miss_count, 1)
71
self.assertEquals(hc.hit_count, 2)
73
73
# write new file and make sure it is seen
74
74
file('foo', 'wb').write('goodbye')
76
76
self.assertEquals(hc.get_sha1('foo'),
77
77
'3c8ec4874488f6090a157b014ce3397ca8e06d4f')
78
##self.assertEquals(hc.miss_count, 2)
78
self.assertEquals(hc.miss_count, 2)
80
80
# quickly write new file of same size and make sure it is seen
81
81
# this may rely on detection of timestamps that are too close
102
102
# should now be safe to cache it if we reread them
103
103
self.assertEquals(hc.get_sha1('foo'), sha1('g00dbye'))
104
##self.assertEquals(len(hc._cache), 1)
104
self.assertEquals(len(hc._cache), 1)
105
105
self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))
106
##self.assertEquals(len(hc._cache), 2)
106
self.assertEquals(len(hc._cache), 2)
108
108
# write out, read back in and check that we don't need to
109
109
# re-read any files
113
113
hc = HashCache(u'.')
116
##self.assertEquals(len(hc._cache), 2)
116
self.assertEquals(len(hc._cache), 2)
117
117
self.assertEquals(hc.get_sha1('foo'), sha1('g00dbye'))
118
##self.assertEquals(hc.hit_count, 1)
119
##self.assertEquals(hc.miss_count, 0)
118
self.assertEquals(hc.hit_count, 1)
119
self.assertEquals(hc.miss_count, 0)
120
120
self.assertEquals(hc.get_sha1('foo2'), sha1('new content'))