def test_merge_index(self): merged_index = hashedindex.merge([self.first_index, self.second_index]) assert unordered_list_cmp(merged_index.terms(), ["foo", "bar"]) assert unordered_list_cmp(merged_index.documents(), ["document1.txt", "document2.txt", "document9.txt"]) assert merged_index._terms["foo"] == {"document1.txt": 2, "document2.txt": 1} assert merged_index._terms["bar"] == {"document9.txt": 1} assert merged_index._documents["document1.txt"] == 2 assert merged_index._documents["document2.txt"] == 1 assert merged_index._documents["document9.txt"] == 1
def test_merge_index(self): merged_index = hashedindex.merge([ self.first_index, self.second_index, ]) assert unordered_list_cmp(merged_index.terms(), ['foo', 'bar']) assert unordered_list_cmp( merged_index.documents(), ['document1.txt', 'document2.txt', 'document9.txt']) assert merged_index._terms['foo'] == { 'document1.txt': 2, 'document2.txt': 1 } assert merged_index._terms['bar'] == {'document9.txt': 1} assert merged_index._documents['document1.txt'] == 2 assert merged_index._documents['document2.txt'] == 1 assert merged_index._documents['document9.txt'] == 1
def test_merge_index_single(self): assert hashedindex.merge([self.first_index]) == self.first_index
def test_merge_index_empty(self): assert hashedindex.merge([]) == hashedindex.HashedIndex()