latest changes

This commit is contained in:
Joren de Graaf
2026-10-17 11:38:57 +02:00
parent 86e3afaca7
commit 76c76bc281
31 changed files with 4562 additions and 41 deletions
+27
View File
@@ -173,6 +173,33 @@ class McpHttpTests(LiveServerTestCase):
asyncio.run(self._client(self.secret, check))
def test_inventory_bulk_update_and_delete_tools(self):
location = InventoryLocation.objects.create(user=self.a, name='Pantry')
items = [KitchenInventoryItem.objects.create(user=self.a, product=self.a_product, location=location)
for _ in range(2)]
ids = [str(item.api_id) for item in items]
async def check(client):
names = {tool.name for tool in (await client.list_tools()).tools}
self.assertIn('inventory_bulk_update', names)
self.assertIn('inventory_bulk_delete', names)
update = {'items': [{'item_id': identifier, 'changes': {'location': 'Metal shelf'}} for identifier in ids]}
preview = (await client.call_tool('inventory_bulk_update', update)).structured_content
self.assertEqual(preview['counts']['validated'], 2)
apply = {**update, 'dry_run': False, 'idempotency_key': 'mcp-bulk-update-1'}
changed = (await client.call_tool('inventory_bulk_update', apply)).structured_content
self.assertEqual(changed['counts']['changed'], 2)
self.assertEqual((await client.call_tool('inventory_bulk_update', apply)).structured_content, changed)
deletion = {'item_ids': ids}
self.assertEqual((await client.call_tool('inventory_bulk_delete', deletion)).structured_content['counts']['validated'], 2)
self.assertTrue((await client.call_tool('inventory_bulk_delete', {**deletion, 'dry_run': False})).is_error)
removed = (await client.call_tool('inventory_bulk_delete', {
**deletion, 'dry_run': False, 'confirm': True, 'idempotency_key': 'mcp-bulk-delete-1'})).structured_content
self.assertEqual(removed['counts']['changed'], 2)
asyncio.run(self._client(self.secret, check))
self.assertEqual(KitchenInventoryItem.objects.filter(pk__in=[item.pk for item in items], archived_at__isnull=False).count(), 2)
def test_oauth_issued_pat_authenticates_mcp(self):
application = Application.objects.create(user=self.a, name='Test ChatGPT style client',
client_type=Application.CLIENT_PUBLIC, authorization_grant_type=Application.GRANT_AUTHORIZATION_CODE,