2157
2159
key = ('foo', 'bar',)
2158
2160
files.add_lines(key, (), [])
2159
2161
self.assertEqual(set([key]), set(files.keys()))
2164
class VirtualVersionedFilesTests(TestCase):
2165
"""Basic tests for the VirtualVersionedFiles implementations."""
2167
def _get_parent_map(self, keys):
2170
if k in self._parent_map:
2171
ret[k] = self._parent_map[k]
2175
TestCase.setUp(self)
2177
self._parent_map = {}
2178
self.texts = VirtualVersionedFiles(self._get_parent_map,
2181
def test_add_lines(self):
2182
self.assertRaises(NotImplementedError,
2183
self.texts.add_lines, "foo", [], [])
2185
def test_add_mpdiffs(self):
2186
self.assertRaises(NotImplementedError,
2187
self.texts.add_mpdiffs, [])
2189
def test_check(self):
2190
self.assertTrue(self.texts.check())
2192
def test_insert_record_stream(self):
2193
self.assertRaises(NotImplementedError, self.texts.insert_record_stream,
2196
def test_get_sha1s_nonexistent(self):
2197
self.assertEquals({}, self.texts.get_sha1s([("NONEXISTENT",)]))
2199
def test_get_sha1s(self):
2200
self._lines["key"] = ["dataline1", "dataline2"]
2201
self.assertEquals({("key",): osutils.sha_strings(self._lines["key"])},
2202
self.texts.get_sha1s([("key",)]))
2204
def test_get_parent_map(self):
2205
self._parent_map = {"G": ("A", "B")}
2206
self.assertEquals({("G",): (("A",),("B",))},
2207
self.texts.get_parent_map([("G",), ("L",)]))
2209
def test_get_record_stream(self):
2210
self._lines["A"] = ["FOO", "BAR"]
2211
it = self.texts.get_record_stream([("A",)], "unordered", True)
2213
self.assertEquals("fulltext", record.storage_kind)
2214
self.assertEquals("FOOBAR", record.get_bytes_as("fulltext"))
2216
def test_get_record_stream_absent(self):
2217
it = self.texts.get_record_stream([("A",)], "unordered", True)
2219
self.assertEquals("absent", record.storage_kind)