haystack/releasenotes/notes/document-store-testing-c1a8050f06ff3e97.yaml
Silvano Cerza 9a7fd6f2ce
refactor: Add new filters tests for Document Store testing (#6428)
* Add new filters tests for Document Store testing

* Add release notes
2023-11-28 09:57:08 +01:00

26 lines
1.2 KiB
YAML

---
prelude: >
The `testing.DocumentStoreBaseTests` has been heavily overhauled.
It has been split into multiple classes so developers can gradually test their Document Store as they're implemented.
`DocumentStoreBaseTests` now inherits from this classes:
- `CountDocumentsTest`, to test `DocumentStore.count_documents()`
- `WriteDocumentsTest`, to test `DocumentStore.write_documents()`
- `DeleteDocumentsTest`, to test `DocumentStore.delete_documents()`
- `FilterDocumentsTest`, to test `DocumentStore.filter_documents()`
To use each class it's enough to inherit from it and define the `document_store` fixture to return an instance of the Document Store we're implementing.
```python
class MyDocumentStoreCountDocumentTest(CountDocumentsTest):
@pytest.fixture
def document_store(self):
return MyDocumentStore()
```
There's also another class that tests `DocumentStore.filter_documents()` using legacy filters.
This is not inherited by `DocumentStoreBaseTests` but can be added as a base class to verify the support of legacy filters.
- `LegacyFilterDocumentsTest`
preview:
- |
Rework the `testing.DocumentStoreBaseTests` class to ease Document Stores development and testing