131
131
sha1:123456789012345678901234567890abcdefabcd\x00\x001 2 3 4
134
_large_offsets = """type=leaf
135
sha1:123456789012345678901234567890abcdefabcd\x00\x0012345678901 1234567890 0 1
136
sha1:abcd123456789012345678901234567890abcdef\x00\x002147483648 2147483647 0 1
137
sha1:abcdefabcd123456789012345678901234567890\x00\x004294967296 4294967295 4294967294 1
134
140
_multi_key_content = """type=leaf
135
141
sha1:123456789012345678901234567890abcdefabcd\x00\x001 2 3 4
136
142
sha1:abcd123456789012345678901234567890abcdef\x00\x005678 2345 3456 4567
163
169
def test_one_key_leaf(self):
164
170
leaf = self.module._parse_into_chk(_one_key_content, 1, 0)
165
171
self.assertEqual(1, len(leaf))
166
sha_key = ('sha1:123456789012345678901234567890abcdefabcd',)
172
sha_key = ('sha1:' + _hex_form,)
167
173
self.assertEqual([sha_key], leaf.all_keys())
168
174
self.assertEqual([(sha_key, ('1 2 3 4', ()))], leaf.all_items())
169
175
self.assertTrue(sha_key in leaf)
177
def test_large_offsets(self):
178
leaf = self.module._parse_into_chk(_large_offsets, 1, 0)
179
self.assertEqual(['12345678901 1234567890 0 1',
180
'2147483648 2147483647 0 1',
181
'4294967296 4294967295 4294967294 1',
182
], [x[1][0] for x in leaf.all_items()])
171
184
def test_many_key_leaf(self):
172
185
leaf = self.module._parse_into_chk(_multi_key_content, 1, 0)
173
186
self.assertEqual(2, len(leaf))
174
sha_key1 = ('sha1:123456789012345678901234567890abcdefabcd',)
187
sha_key1 = ('sha1:' + _hex_form,)
175
188
sha_key2 = ('sha1:abcd123456789012345678901234567890abcdef',)
176
189
self.assertEqual([sha_key1, sha_key2], leaf.all_keys())
177
190
self.assertEqual([(sha_key1, ('1 2 3 4', ())),