Skip to content

Commit 8bcc09c

Browse files
rakduttakevalmahajan
authored andcommitted
pytest
Signed-off-by: rakdutta <rakhibiswas@yahoo.com>
1 parent 93115d7 commit 8bcc09c

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

tests/unit/mcpgateway/services/test_resource_service.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def mock_resource():
7373
resource.text_content = "Test content"
7474
resource.binary_content = None
7575
resource.size = 12
76-
resource.is_active = True
76+
resource.enabled = True
7777
resource.created_by = "test_user"
7878
resource.modified_by = "test_user"
7979
resource.created_at = datetime.now(timezone.utc)
@@ -110,7 +110,7 @@ def mock_resource_template():
110110
resource.text_content = "Test content"
111111
resource.binary_content = None
112112
resource.size = 12
113-
resource.is_active = True
113+
resource.enabled = True
114114
resource.created_by = "test_user"
115115
resource.modified_by = "test_user"
116116
resource.created_at = datetime.now(timezone.utc)
@@ -147,7 +147,7 @@ def mock_inactive_resource():
147147
resource.text_content = None
148148
resource.binary_content = None
149149
resource.size = 0
150-
resource.is_active = False
150+
resource.enabled = False
151151
resource.created_by = "test_user"
152152
resource.modified_by = "test_user"
153153
resource.created_at = datetime.now(timezone.utc)
@@ -230,7 +230,7 @@ async def test_register_resource_success(self, resource_service, mock_db, sample
230230
description=sample_resource_create.description or "",
231231
mime_type="text/plain",
232232
size=len(sample_resource_create.content),
233-
is_active=True,
233+
enabled=True,
234234
created_at=datetime.now(timezone.utc),
235235
updated_at=datetime.now(timezone.utc),
236236
template=None,
@@ -346,7 +346,7 @@ async def test_register_resource_binary_content(self, resource_service, mock_db)
346346
description=binary_resource.description or "",
347347
mime_type="application/octet-stream",
348348
size=len(binary_resource.content),
349-
is_active=True,
349+
enabled=True,
350350
created_at=datetime.now(timezone.utc),
351351
updated_at=datetime.now(timezone.utc),
352352
template=None,
@@ -552,7 +552,7 @@ async def test_toggle_resource_status_activate(self, resource_service, mock_db,
552552
description=mock_inactive_resource.description or "",
553553
mime_type=mock_inactive_resource.mime_type or "text/plain",
554554
size=mock_inactive_resource.size or 0,
555-
is_active=True,
555+
enabled=True,
556556
created_at=datetime.now(timezone.utc),
557557
updated_at=datetime.now(timezone.utc),
558558
template=None,
@@ -570,7 +570,7 @@ async def test_toggle_resource_status_activate(self, resource_service, mock_db,
570570

571571
result = await resource_service.toggle_resource_status(mock_db, 2, activate=True)
572572

573-
assert mock_inactive_resource.is_active is True
573+
assert mock_inactive_resource.enabled is True
574574
mock_db.commit.assert_called_once()
575575

576576
@pytest.mark.asyncio
@@ -586,7 +586,7 @@ async def test_toggle_resource_status_deactivate(self, resource_service, mock_db
586586
description=mock_resource.description,
587587
mime_type=mock_resource.mime_type,
588588
size=mock_resource.size,
589-
is_active=False,
589+
enabled=False,
590590
created_at=datetime.now(timezone.utc),
591591
updated_at=datetime.now(timezone.utc),
592592
template=None,
@@ -604,7 +604,7 @@ async def test_toggle_resource_status_deactivate(self, resource_service, mock_db
604604

605605
result = await resource_service.toggle_resource_status(mock_db, 1, activate=False)
606606

607-
assert mock_resource.is_active is False
607+
assert mock_resource.enabled is False
608608
mock_db.commit.assert_called_once()
609609

610610
@pytest.mark.asyncio
@@ -622,7 +622,7 @@ async def test_toggle_resource_status_not_found(self, resource_service, mock_db)
622622
async def test_toggle_resource_status_no_change(self, resource_service, mock_db, mock_resource):
623623
"""Test toggling status when no change needed."""
624624
mock_db.get.return_value = mock_resource
625-
mock_resource.is_active = True
625+
mock_resource.enabled = True
626626

627627
with patch.object(resource_service, "_convert_resource_to_read") as mock_convert:
628628
mock_convert.return_value = ResourceRead(
@@ -632,7 +632,7 @@ async def test_toggle_resource_status_no_change(self, resource_service, mock_db,
632632
description=mock_resource.description,
633633
mime_type=mock_resource.mime_type,
634634
size=mock_resource.size,
635-
is_active=True,
635+
enabled=True,
636636
created_at=datetime.now(timezone.utc),
637637
updated_at=datetime.now(timezone.utc),
638638
template=None,
@@ -673,7 +673,7 @@ async def test_update_resource_success(self, resource_service, mock_db, mock_res
673673
description="Updated description",
674674
mime_type="text/plain",
675675
size=15, # length of "Updated content"
676-
is_active=True,
676+
enabled=True,
677677
created_at=datetime.now(timezone.utc),
678678
updated_at=datetime.now(timezone.utc),
679679
template=None,
@@ -746,7 +746,7 @@ async def test_update_resource_binary_content(self, resource_service, mock_db, m
746746
description=mock_resource.description,
747747
mime_type="application/octet-stream",
748748
size=len(b"new binary content"),
749-
is_active=True,
749+
enabled=True,
750750
created_at=datetime.now(timezone.utc),
751751
updated_at=datetime.now(timezone.utc),
752752
template=None,
@@ -1355,7 +1355,7 @@ async def test_notify_resource_activated(self, resource_service, mock_resource):
13551355
resource_service._event_service.publish_event.assert_called_once()
13561356
call_args = resource_service._event_service.publish_event.call_args[0][0]
13571357
assert call_args["type"] == "resource_activated"
1358-
assert call_args["data"]["is_active"] is True
1358+
assert call_args["data"]["enabled"] is True
13591359

13601360
@pytest.mark.asyncio
13611361
async def test_notify_resource_deactivated(self, resource_service, mock_resource):
@@ -1367,7 +1367,7 @@ async def test_notify_resource_deactivated(self, resource_service, mock_resource
13671367
resource_service._event_service.publish_event.assert_called_once()
13681368
call_args = resource_service._event_service.publish_event.call_args[0][0]
13691369
assert call_args["type"] == "resource_deactivated"
1370-
assert call_args["data"]["is_active"] is False
1370+
assert call_args["data"]["enabled"] is False
13711371

13721372
@pytest.mark.asyncio
13731373
async def test_notify_resource_deleted(self, resource_service):

tests/unit/mcpgateway/test_admin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ async def test_admin_get_prompt_with_detailed_metrics(self, mock_get_prompt_deta
920920
"arguments": [{"name": "var", "type": "string"}],
921921
"created_at": datetime.now(timezone.utc),
922922
"updated_at": datetime.now(timezone.utc),
923-
"is_active": True,
923+
"enabled": True,
924924
"metrics": {
925925
"total_executions": 1000,
926926
"successful_executions": 950,

0 commit comments

Comments
 (0)