Skip to content

Commit 874c602

Browse files
Unit test cases added
1 parent bbb4a32 commit 874c602

File tree

2 files changed

+245
-0
lines changed

2 files changed

+245
-0
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
"""Test cases for ProcurementTools class."""
2+
import pytest
3+
from src.backend.kernel_tools.hr_tools import HrTools
4+
5+
6+
@pytest.mark.asyncio
7+
async def test_schedule_orientation_session():
8+
"""Test schedule_orientation_session method."""
9+
result = await HrTools.schedule_orientation_session("John Doe", "2025-05-20")
10+
assert "Orientation Session Scheduled" in result
11+
assert "**Employee Name:** John Doe" in result
12+
assert "**Date:** 2025-05-20" in result
13+
14+
15+
@pytest.mark.asyncio
16+
async def test_assign_mentor():
17+
"""Test assign_mentor method."""
18+
result = await HrTools.assign_mentor("Jane Doe")
19+
assert "Mentor Assigned" in result
20+
assert "**Employee Name:** Jane Doe" in result
21+
22+
23+
@pytest.mark.asyncio
24+
async def test_register_for_benefits():
25+
"""Test register_for_benefits method."""
26+
result = await HrTools.register_for_benefits("John Doe")
27+
assert "Benefits Registration" in result
28+
assert "**Employee Name:** John Doe" in result
29+
30+
31+
@pytest.mark.asyncio
32+
async def test_enroll_in_training_program():
33+
"""Test enroll_in_training_program method."""
34+
result = await HrTools.enroll_in_training_program("John Doe", "Leadership Training")
35+
assert "Training Program Enrollment" in result
36+
assert "**Employee Name:** John Doe" in result
37+
assert "**Program Name:** Leadership Training" in result
38+
39+
40+
@pytest.mark.asyncio
41+
async def test_provide_employee_handbook():
42+
"""Test provide_employee_handbook method."""
43+
result = await HrTools.provide_employee_handbook("Jane Doe")
44+
assert "Employee Handbook Provided" in result
45+
assert "**Employee Name:** Jane Doe" in result
46+
47+
48+
@pytest.mark.asyncio
49+
async def test_update_employee_record():
50+
"""Test update_employee_record method."""
51+
result = await HrTools.update_employee_record("John Doe", "Address", "123 Main St")
52+
assert "Employee Record Updated" in result
53+
assert "**Field Updated:** Address" in result
54+
assert "**New Value:** 123 Main St" in result
55+
56+
57+
@pytest.mark.asyncio
58+
async def test_request_id_card():
59+
"""Test request_id_card method."""
60+
result = await HrTools.request_id_card("John Doe")
61+
assert "ID Card Request" in result
62+
assert "**Employee Name:** John Doe" in result
63+
64+
65+
@pytest.mark.asyncio
66+
async def test_set_up_payroll():
67+
"""Test set_up_payroll method."""
68+
result = await HrTools.set_up_payroll("Jane Doe")
69+
assert "Payroll Setup" in result
70+
assert "**Employee Name:** Jane Doe" in result
71+
72+
73+
@pytest.mark.asyncio
74+
async def test_add_emergency_contact():
75+
"""Test add_emergency_contact method."""
76+
result = await HrTools.add_emergency_contact("John Doe", "Jane Smith", "555-1234")
77+
assert "Emergency Contact Added" in result
78+
assert "**Contact Name:** Jane Smith" in result
79+
assert "**Contact Phone:** 555-1234" in result
80+
81+
82+
@pytest.mark.asyncio
83+
async def test_process_leave_request():
84+
"""Test process_leave_request method."""
85+
result = await HrTools.process_leave_request("John Doe", "Vacation", "2025-06-01", "2025-06-10")
86+
assert "Leave Request Processed" in result
87+
assert "**Leave Type:** Vacation" in result
88+
assert "**Start Date:** 2025-06-01" in result
89+
assert "**End Date:** 2025-06-10" in result
90+
91+
92+
def test_get_all_kernel_functions():
93+
"""Test get_all_kernel_functions method."""
94+
kernel_functions = HrTools.get_all_kernel_functions()
95+
assert "schedule_orientation_session" in kernel_functions
96+
assert "assign_mentor" in kernel_functions
97+
assert callable(kernel_functions["schedule_orientation_session"])
98+
99+
100+
def test_generate_tools_json_doc():
101+
"""Test generate_tools_json_doc method."""
102+
tools_json = HrTools.generate_tools_json_doc()
103+
assert "schedule_orientation_session" in tools_json
104+
assert "assign_mentor" in tools_json
105+
assert "arguments" in tools_json
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
"""Test cases for ProcurementTools class."""
2+
import pytest
3+
from src.backend.kernel_tools.procurement_tools import ProcurementTools
4+
5+
6+
@pytest.mark.asyncio
7+
async def test_order_hardware():
8+
"""Test order_hardware method."""
9+
result = await ProcurementTools.order_hardware("Laptop", 5)
10+
assert "Hardware Order Placed" in result
11+
assert "**Item:** Laptop" in result
12+
assert "**Quantity:** 5" in result
13+
14+
15+
@pytest.mark.asyncio
16+
async def test_order_software_license():
17+
"""Test order_software_license method."""
18+
result = await ProcurementTools.order_software_license("Microsoft Office", "Enterprise", 10)
19+
assert "Software License Ordered" in result
20+
assert "**Software:** Microsoft Office" in result
21+
assert "**License Type:** Enterprise" in result
22+
assert "**Quantity:** 10" in result
23+
24+
25+
@pytest.mark.asyncio
26+
async def test_check_inventory():
27+
"""Test check_inventory method."""
28+
result = await ProcurementTools.check_inventory("Laptop")
29+
assert "Inventory Status" in result
30+
assert "**Item:** Laptop" in result
31+
assert "**Status:** In Stock" in result
32+
33+
34+
@pytest.mark.asyncio
35+
async def test_process_purchase_order():
36+
"""Test process_purchase_order method."""
37+
result = await ProcurementTools.process_purchase_order("PO12345")
38+
assert "Purchase Order Processed" in result
39+
assert "**PO Number:** PO12345" in result
40+
41+
42+
@pytest.mark.asyncio
43+
async def test_initiate_contract_negotiation():
44+
"""Test initiate_contract_negotiation method."""
45+
result = await ProcurementTools.initiate_contract_negotiation("Vendor A", "Contract Details")
46+
assert "Contract Negotiation Initiated" in result
47+
assert "**Vendor:** Vendor A" in result
48+
assert "**Contract Details:** Contract Details" in result
49+
50+
51+
@pytest.mark.asyncio
52+
async def test_approve_invoice():
53+
"""Test approve_invoice method."""
54+
result = await ProcurementTools.approve_invoice("INV12345")
55+
assert "Invoice Approved" in result
56+
assert "**Invoice Number:** INV12345" in result
57+
58+
59+
@pytest.mark.asyncio
60+
async def test_track_order():
61+
"""Test track_order method."""
62+
result = await ProcurementTools.track_order("ORD12345")
63+
assert "Order Tracking" in result
64+
assert "**Order Number:** ORD12345" in result
65+
assert "**Status:** In Transit" in result
66+
67+
68+
@pytest.mark.asyncio
69+
async def test_manage_vendor_relationship():
70+
"""Test manage_vendor_relationship method."""
71+
result = await ProcurementTools.manage_vendor_relationship("Vendor A", "updated")
72+
assert "Vendor Relationship Update" in result
73+
assert "**Vendor:** Vendor A" in result
74+
assert "**Action:** updated" in result
75+
76+
77+
@pytest.mark.asyncio
78+
async def test_update_procurement_policy():
79+
"""Test update_procurement_policy method."""
80+
result = await ProcurementTools.update_procurement_policy("Policy A", "New Policy Content")
81+
assert "Procurement Policy Updated" in result
82+
assert "**Policy:** Policy A" in result
83+
84+
85+
def test_get_all_kernel_functions():
86+
"""Test get_all_kernel_functions method."""
87+
kernel_functions = ProcurementTools.get_all_kernel_functions()
88+
assert "order_hardware" in kernel_functions
89+
assert "order_software_license" in kernel_functions
90+
assert callable(kernel_functions["order_hardware"])
91+
92+
93+
def test_generate_tools_json_doc():
94+
"""Test generate_tools_json_doc method."""
95+
tools_json = ProcurementTools.generate_tools_json_doc()
96+
assert "order_hardware" in tools_json
97+
assert "order_software_license" in tools_json
98+
assert "arguments" in tools_json
99+
100+
101+
@pytest.mark.asyncio
102+
async def test_order_hardware_invalid_quantity():
103+
"""Test order_hardware with invalid quantity."""
104+
result = await ProcurementTools.order_hardware("Laptop", 0)
105+
assert "Hardware Order Placed" in result
106+
assert "**Quantity:** 0" in result
107+
108+
109+
@pytest.mark.asyncio
110+
async def test_order_software_license_invalid_quantity():
111+
"""Test order_software_license with invalid quantity."""
112+
result = await ProcurementTools.order_software_license("Microsoft Office", "Enterprise", -1)
113+
assert "Software License Ordered" in result
114+
assert "**Quantity:** -1" in result
115+
116+
117+
# @pytest.mark.asyncio
118+
# async def test_check_inventory_item_not_found():
119+
# """Test check_inventory with an item not found."""
120+
# result = await ProcurementTools.check_inventory("NonExistentItem")
121+
# assert "Inventory Status" in result
122+
# assert "**Item:** NonExistentItem" in result
123+
# assert "**Status:** Not Found" in result
124+
125+
126+
@pytest.mark.asyncio
127+
async def test_process_purchase_order_invalid_po():
128+
"""Test process_purchase_order with an invalid PO number."""
129+
result = await ProcurementTools.process_purchase_order("")
130+
assert "Purchase Order Processed" in result
131+
assert "**PO Number:** " in result
132+
133+
134+
@pytest.mark.asyncio
135+
async def test_initiate_contract_negotiation_empty_details():
136+
"""Test initiate_contract_negotiation with empty contract details."""
137+
result = await ProcurementTools.initiate_contract_negotiation("Vendor A", "")
138+
assert "Contract Negotiation Initiated" in result
139+
assert "**Vendor:** Vendor A" in result
140+
assert "**Contract Details:** " in result

0 commit comments

Comments
 (0)