|
6 | 6 | from _pytest.fixtures import SubRequest
|
7 | 7 |
|
8 | 8 | import weaviate
|
| 9 | +import weaviate.classes as wvc |
9 | 10 | from integration.conftest import _sanitize_collection_name
|
10 | 11 | from weaviate.collections.classes.batch import Shard
|
11 | 12 | from weaviate.collections.classes.config import (
|
@@ -587,3 +588,37 @@ def test_uuids_keys_and_original_index(client_factory: ClientFactory) -> None:
|
587 | 588 | assert [objs[k][0] for k in client.batch.results.objs.uuids.keys()] == list(
|
588 | 589 | client.batch.results.objs.uuids.values()
|
589 | 590 | )
|
| 591 | + |
| 592 | + |
| 593 | +def test_references_with_to_uuids(client_factory: ClientFactory) -> None: |
| 594 | + """Test that batch waits until the to object is created.""" |
| 595 | + client, name = client_factory() |
| 596 | + |
| 597 | + client.collections.delete(["target", "source"]) |
| 598 | + target = client.collections.create( |
| 599 | + "target", multi_tenancy_config=wvc.config.Configure.multi_tenancy(enabled=True) |
| 600 | + ) |
| 601 | + source = client.collections.create( |
| 602 | + "source", |
| 603 | + references=[wvc.config.ReferenceProperty(name="to", target_collection="target")], |
| 604 | + multi_tenancy_config=wvc.config.Configure.multi_tenancy(enabled=True), |
| 605 | + ) |
| 606 | + |
| 607 | + target.tenants.create("tenant-1") |
| 608 | + source.tenants.create("tenant-1") |
| 609 | + from_uuid = source.with_tenant("tenant-1").data.insert(properties={}) |
| 610 | + objs = 20 |
| 611 | + |
| 612 | + with client.batch.fixed_size(batch_size=10, concurrent_requests=1) as batch: |
| 613 | + for _ in range(objs): |
| 614 | + to = batch.add_object(collection="target", properties={}, tenant="tenant-1") |
| 615 | + batch.add_reference( |
| 616 | + from_uuid=from_uuid, |
| 617 | + from_property="to", |
| 618 | + to=to, |
| 619 | + from_collection="source", |
| 620 | + tenant="tenant-1", |
| 621 | + ) |
| 622 | + |
| 623 | + assert len(client.batch.failed_references) == 0, client.batch.failed_references |
| 624 | + client.collections.delete(["target", "source"]) |
0 commit comments