Skip to content

Commit c9c6254

Browse files
hkulekciclaude
andcommitted
Fix failing tests for RecommendRequest, BatchRecommendRequest, and Service
Add required setLimit() calls to RecommendRequest and BatchRecommendRequest tests to match the limit validation added in the previous commit. Remove locks tests from ServiceTest as the /locks endpoint has been removed from the Qdrant API, and mark getLocks/setLocks methods as deprecated. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 294f866 commit c9c6254

4 files changed

Lines changed: 34 additions & 41 deletions

File tree

src/Endpoints/Service.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,10 @@ public function metrics(bool $anonymize): Response
4141
}
4242

4343
/**
44-
* # Delete storage snapshot
45-
* Delete snapshot of the whole storage
44+
* # Set lock options
45+
* Set lock options for the storage
4646
*
47+
* @deprecated This endpoint has been removed from the Qdrant API.
4748
* @throws InvalidArgumentException
4849
*/
4950
public function setLocks(ServiceLock $body): Response
@@ -54,9 +55,10 @@ public function setLocks(ServiceLock $body): Response
5455
}
5556

5657
/**
57-
* # Download storage snapshot
58-
* Download specified snapshot of the whole storage as a file
58+
* # Get lock options
59+
* Get lock options for the storage
5960
*
61+
* @deprecated This endpoint has been removed from the Qdrant API.
6062
* @throws InvalidArgumentException
6163
*/
6264
public function getLocks(): Response

tests/Integration/Endpoints/ServiceTest.php

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
use Qdrant\Endpoints\Service;
1010
use Qdrant\Exception\InvalidArgumentException;
11-
use Qdrant\Models\Request\ServiceLock;
1211
use Qdrant\Tests\Integration\AbstractIntegration;
1312

1413
class ServiceTest extends AbstractIntegration
@@ -42,32 +41,4 @@ public function testServiceMetrics(): void
4241
$this->assertStringContainsString('collections_total', $response['content']);
4342
$this->assertStringContainsString('rest_responses_', $response['content']);
4443
}
45-
46-
/**
47-
* @throws InvalidArgumentException
48-
*/
49-
public function testServiceGetLocks(): void
50-
{
51-
$service = new Service($this->client);
52-
$response = $service->getLocks();
53-
$this->assertEquals('ok', $response['status']);
54-
$this->assertArrayHasKey('result', $response);
55-
}
56-
57-
/**
58-
* @throws InvalidArgumentException
59-
*/
60-
public function testServiceSetLocks(): void
61-
{
62-
$service = new Service($this->client);
63-
64-
$response = $service->setLocks(new ServiceLock(true));
65-
$this->assertEquals('ok', $response['status']);
66-
$this->assertArrayHasKey('result', $response);
67-
68-
// Revert back to False
69-
$response = $service->setLocks(new ServiceLock(false));
70-
$this->assertEquals('ok', $response['status']);
71-
$this->assertArrayHasKey('result', $response);
72-
}
73-
}
44+
}

tests/Unit/Models/Request/Points/BatchRecommendRequestTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,23 @@ class BatchRecommendRequestTest extends TestCase
1717
public function testBasicRecommendRequest(): void
1818
{
1919
$request = new BatchRecommendRequest([
20-
new RecommendRequest([100, 101], [110]),
21-
new RecommendRequest([101, 102], [112]),
20+
(new RecommendRequest([100, 101], [110]))->setLimit(10),
21+
(new RecommendRequest([101, 102], [112]))->setLimit(10),
2222
]);
2323

2424
$this->assertEquals([
2525
'searches' =>[
2626
[
2727
'positive' => [100, 101],
2828
'negative' => [110],
29+
'limit' => 10,
2930
],
3031
[
3132
'positive' => [101, 102],
3233
'negative' => [112],
34+
'limit' => 10,
3335
]
3436
]
3537
], $request->toArray());
3638
}
37-
}
39+
}

tests/Unit/Models/Request/Points/RecommendRequestTest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,28 @@ class RecommendRequestTest extends TestCase
1616
{
1717
public function testBasicRecommendRequest(): void
1818
{
19-
$request = new RecommendRequest([100, 101], [110]);
19+
$request = (new RecommendRequest([100, 101], [110]))
20+
->setLimit(10);
2021

2122
$this->assertEquals([
2223
'positive' => [100, 101],
2324
'negative' => [110],
25+
'limit' => 10,
2426
], $request->toArray());
2527
}
2628

29+
public function testRecommendRequestWithoutLimitThrowsException(): void
30+
{
31+
$request = new RecommendRequest([100, 101], [110]);
32+
33+
$this->expectException(InvalidArgumentException::class);
34+
$request->toArray();
35+
}
36+
2737
public function testRecommendRequestWithFilter(): void
2838
{
2939
$request = (new RecommendRequest([100, 101], [110]))
40+
->setLimit(10)
3041
->setFilter(
3142
(new Filter())->addMust((new MatchExcept('foo', ['bar'])))
3243
);
@@ -43,13 +54,15 @@ public function testRecommendRequestWithFilter(): void
4354
]
4455
]
4556
]
46-
]
57+
],
58+
'limit' => 10,
4759
], $request->toArray());
4860
}
4961

5062
public function testRecommendRequestWithScoreThreshold(): void
5163
{
5264
$request = (new RecommendRequest([100, 101], [110]))
65+
->setLimit(10)
5366
->setFilter(
5467
(new Filter())->addMust((new MatchExcept('foo', ['bar'])))
5568
)
@@ -68,31 +81,36 @@ public function testRecommendRequestWithScoreThreshold(): void
6881
]
6982
]
7083
]
71-
]
84+
],
85+
'limit' => 10,
7286
], $request->toArray());
7387
}
7488

7589
public function testRecommendRequestWithOffset(): void
7690
{
7791
$request = (new RecommendRequest([100, 101], [110]))
92+
->setLimit(10)
7893
->setOffset(1);
7994

8095
$this->assertEquals([
8196
'positive' => [100, 101],
8297
'negative' => [110],
98+
'limit' => 10,
8399
'offset'=> 1,
84100
], $request->toArray());
85101
}
86102

87103
public function testRecommendRequestWithUsing(): void
88104
{
89105
$request = (new RecommendRequest([100, 101], [110]))
106+
->setLimit(10)
90107
->setUsing('foo');
91108

92109
$this->assertEquals([
93110
'positive' => [100, 101],
94111
'negative' => [110],
95112
'using'=> 'foo',
113+
'limit' => 10,
96114
], $request->toArray());
97115
}
98116

@@ -142,4 +160,4 @@ public function testRecommendRequestWithLimitAndStrategy(): void
142160
'strategy' => RecommendRequest::STRATEGY_AVERAGE_VECTOR
143161
], $request->toArray());
144162
}
145-
}
163+
}

0 commit comments

Comments
 (0)