Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 def test_merge_index_single(self):
     assert hashedindex.merge([self.first_index]) == self.first_index
Exemplo n.º 4
0
 def test_merge_index_empty(self):
     assert hashedindex.merge([]) == hashedindex.HashedIndex()
Exemplo n.º 5
0
 def test_merge_index_single(self):
     assert hashedindex.merge([self.first_index]) == self.first_index
Exemplo n.º 6
0
 def test_merge_index_empty(self):
     assert hashedindex.merge([]) == hashedindex.HashedIndex()