Skip to content

Commit 4ac8017

Browse files
author
Radoslav Klic
committed
AI-1169 add links to more tests
1 parent 47243d5 commit 4ac8017

File tree

4 files changed

+51
-3
lines changed

4 files changed

+51
-3
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def keboola_client(mocker) -> KeboolaClient:
2121
client.storage_client = mocker.MagicMock(AsyncStorageClient)
2222
client.storage_client.base_api_url = 'test://api.keboola.com'
2323
client.storage_client.branch_id = 'default'
24-
client.storage_client.project_id.return_value = '123'
24+
client.storage_client.project_id.return_value = '69420'
2525
client.jobs_queue_client = mocker.MagicMock(JobsQueueClient)
2626
client.ai_service_client = mocker.MagicMock(AIServiceClient)
2727

tests/tools/components/test_tools.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from pytest_mock import MockerFixture
66

77
from keboola_mcp_server.client import KeboolaClient
8+
from keboola_mcp_server.links import Link
89
from keboola_mcp_server.tools.components import (
910
ComponentWithConfigurations,
1011
create_sql_transformation,
@@ -242,6 +243,21 @@ async def test_get_config(
242243
assert result.component is not None
243244
assert result.component.component_id == mock_component['id']
244245
assert result.component.component_name == mock_component['name']
246+
assert set(result.links) == {
247+
Link(
248+
type='ui-detail',
249+
title=f'Configuration: {mock_configuration["name"]}',
250+
url=(
251+
f'test://api.keboola.com/admin/projects/69420/components/'
252+
f'{mock_component["id"]}/{mock_configuration["id"]}'
253+
),
254+
),
255+
Link(
256+
type='ui-dashboard',
257+
title=f'{mock_component["id"]} Configurations Dashboard',
258+
url=f'test://api.keboola.com/admin/projects/69420/components/{mock_component["id"]}',
259+
),
260+
}
245261

246262
# Verify the calls were made with the correct arguments
247263
keboola_client.storage_client.configuration_detail.assert_called_once_with(

tests/tools/test_jobs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,8 @@ async def test_run_job(
244244
assert job_detail.config_id == configuration_id
245245
assert job_detail.result == {}
246246
assert set(job_detail.links) == {
247-
Link(type='ui-detail', title='Job: 123', url='test://api.keboola.com/admin/projects/123/queue/123'),
248-
Link(type='ui-dashboard', title='Jobs in the project', url='test://api.keboola.com/admin/projects/123/queue'),
247+
Link(type='ui-detail', title='Job: 123', url='test://api.keboola.com/admin/projects/69420/queue/123'),
248+
Link(type='ui-dashboard', title='Jobs in the project', url='test://api.keboola.com/admin/projects/69420/queue'),
249249
}
250250

251251
keboola_client.jobs_queue_client.create_job.assert_called_once_with(

tests/tools/test_storage.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from keboola_mcp_server.client import KeboolaClient
99
from keboola_mcp_server.config import Config, MetadataField
10+
from keboola_mcp_server.links import Link
1011
from keboola_mcp_server.tools.storage import (
1112
BucketDetail,
1213
ListBucketsOutput,
@@ -186,6 +187,18 @@ async def test_get_bucket(
186187
assert result.id == expected_bucket['id']
187188
assert result.name == expected_bucket['name']
188189
assert result.display_name == expected_bucket['display_name']
190+
assert set(result.links) == {
191+
Link(
192+
type='ui-detail',
193+
title=f'Bucket: {expected_bucket["name"]}',
194+
url=f'test://api.keboola.com/admin/projects/69420/storage/{bucket_id}',
195+
),
196+
Link(
197+
type='ui-dashboard',
198+
title='Buckets in the project',
199+
url='test://api.keboola.com/admin/projects/69420/storage',
200+
),
201+
}
189202

190203
# Check optional fields only if they are present in the expected bucket
191204
if 'description' in expected_bucket:
@@ -257,6 +270,25 @@ async def test_get_table(
257270
assert result.data_size_bytes == mock_table_data['raw_table_data']['data_size_bytes']
258271
assert result.fully_qualified_name == str(mock_table_data['additional_data']['table_fqn'])
259272
assert result.columns == mock_table_data['additional_data']['columns']
273+
assert set(result.links) == {
274+
Link(
275+
type='ui-detail',
276+
title=f'Table: {mock_table_data["raw_table_data"]["name"]}',
277+
url=(
278+
f'test://api.keboola.com/admin/projects/69420/storage/'
279+
f'{mock_table_data["raw_table_data"]["bucket"]["id"]}/table/'
280+
f'{mock_table_data["raw_table_data"]["name"]}'
281+
),
282+
),
283+
Link(
284+
type='ui-detail',
285+
title=f'Bucket: {mock_table_data["raw_table_data"]["bucket"]["id"]}',
286+
url=(
287+
f'test://api.keboola.com/admin/projects/69420/storage/'
288+
f'{mock_table_data["raw_table_data"]["bucket"]["id"]}'
289+
),
290+
),
291+
}
260292

261293

262294
@pytest.mark.asyncio

0 commit comments

Comments
 (0)