Skip to content

Commit cdd1965

Browse files
Testcases
1 parent 1711b0e commit cdd1965

File tree

2 files changed

+253
-0
lines changed

2 files changed

+253
-0
lines changed
Lines changed: 253 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,253 @@
1+
"""
2+
Test suite for HR-related functions in the backend agents module.
3+
4+
This module contains asynchronous test cases for various HR functions,
5+
including employee orientation, benefits registration, payroll setup, and more.
6+
"""
7+
8+
import os
9+
import sys
10+
from unittest.mock import MagicMock
11+
import pytest
12+
13+
# Set mock environment variables for Azure and CosmosDB
14+
os.environ["COSMOSDB_ENDPOINT"] = "https://mock-endpoint"
15+
os.environ["COSMOSDB_KEY"] = "mock-key"
16+
os.environ["COSMOSDB_DATABASE"] = "mock-database"
17+
os.environ["COSMOSDB_CONTAINER"] = "mock-container"
18+
os.environ["AZURE_OPENAI_DEPLOYMENT_NAME"] = "mock-deployment-name"
19+
os.environ["AZURE_OPENAI_API_VERSION"] = "2023-01-01"
20+
os.environ["AZURE_OPENAI_ENDPOINT"] = "https://mock-openai-endpoint"
21+
22+
# Mock Azure dependencies
23+
sys.modules["azure.monitor.events.extension"] = MagicMock()
24+
25+
# pylint: disable=C0413
26+
from src.backend.agents.hr import (
27+
schedule_orientation_session,
28+
assign_mentor,
29+
register_for_benefits,
30+
enroll_in_training_program,
31+
provide_employee_handbook,
32+
update_employee_record,
33+
request_id_card,
34+
set_up_payroll,
35+
add_emergency_contact,
36+
process_leave_request,
37+
update_policies,
38+
conduct_exit_interview,
39+
verify_employment,
40+
schedule_performance_review,
41+
approve_expense_claim,
42+
send_company_announcement,
43+
fetch_employee_directory,
44+
initiate_background_check,
45+
organize_team_building_activity,
46+
manage_employee_transfer,
47+
track_employee_attendance,
48+
organize_health_and_wellness_program,
49+
facilitate_remote_work_setup,
50+
manage_retirement_plan,
51+
)
52+
# pylint: enable=C0413
53+
54+
@pytest.mark.asyncio
55+
async def test_schedule_orientation_session():
56+
"""Test scheduling an orientation session."""
57+
result = await schedule_orientation_session("John Doe", "2025-02-01")
58+
assert "##### Orientation Session Scheduled" in result
59+
assert "**Employee Name:** John Doe" in result
60+
assert "**Date:** 2025-02-01" in result
61+
62+
63+
@pytest.mark.asyncio
64+
async def test_assign_mentor():
65+
"""Test assigning a mentor to an employee."""
66+
result = await assign_mentor("John Doe")
67+
assert "##### Mentor Assigned" in result
68+
assert "**Employee Name:** John Doe" in result
69+
70+
71+
@pytest.mark.asyncio
72+
async def test_register_for_benefits():
73+
"""Test registering an employee for benefits."""
74+
result = await register_for_benefits("John Doe")
75+
assert "##### Benefits Registration" in result
76+
assert "**Employee Name:** John Doe" in result
77+
78+
79+
@pytest.mark.asyncio
80+
async def test_enroll_in_training_program():
81+
"""Test enrolling an employee in a training program."""
82+
result = await enroll_in_training_program("John Doe", "Leadership 101")
83+
assert "##### Training Program Enrollment" in result
84+
assert "**Employee Name:** John Doe" in result
85+
assert "**Program Name:** Leadership 101" in result
86+
87+
88+
@pytest.mark.asyncio
89+
async def test_provide_employee_handbook():
90+
"""Test providing the employee handbook."""
91+
result = await provide_employee_handbook("John Doe")
92+
assert "##### Employee Handbook Provided" in result
93+
assert "**Employee Name:** John Doe" in result
94+
95+
96+
@pytest.mark.asyncio
97+
async def test_update_employee_record():
98+
"""Test updating an employee record."""
99+
result = await update_employee_record("John Doe", "Email", "[email protected]")
100+
assert "##### Employee Record Updated" in result
101+
assert "**Field Updated:** Email" in result
102+
assert "**New Value:** [email protected]" in result
103+
104+
105+
@pytest.mark.asyncio
106+
async def test_request_id_card():
107+
"""Test requesting an ID card for an employee."""
108+
result = await request_id_card("John Doe")
109+
assert "##### ID Card Request" in result
110+
assert "**Employee Name:** John Doe" in result
111+
112+
113+
@pytest.mark.asyncio
114+
async def test_set_up_payroll():
115+
"""Test setting up payroll for an employee."""
116+
result = await set_up_payroll("John Doe")
117+
assert "##### Payroll Setup" in result
118+
assert "**Employee Name:** John Doe" in result
119+
120+
121+
@pytest.mark.asyncio
122+
async def test_add_emergency_contact():
123+
"""Test adding an emergency contact for an employee."""
124+
result = await add_emergency_contact("John Doe", "Jane Doe", "123-456-7890")
125+
assert "##### Emergency Contact Added" in result
126+
assert "**Contact Name:** Jane Doe" in result
127+
assert "**Contact Phone:** 123-456-7890" in result
128+
129+
130+
@pytest.mark.asyncio
131+
async def test_process_leave_request():
132+
"""Test processing a leave request for an employee."""
133+
result = await process_leave_request(
134+
"John Doe", "Vacation", "2025-03-01", "2025-03-10"
135+
)
136+
assert "##### Leave Request Processed" in result
137+
assert "**Leave Type:** Vacation" in result
138+
assert "**Start Date:** 2025-03-01" in result
139+
assert "**End Date:** 2025-03-10" in result
140+
141+
142+
@pytest.mark.asyncio
143+
async def test_update_policies():
144+
"""Test updating company policies."""
145+
result = await update_policies("Work From Home Policy", "Updated content")
146+
assert "##### Policy Updated" in result
147+
assert "**Policy Name:** Work From Home Policy" in result
148+
assert "Updated content" in result
149+
150+
151+
@pytest.mark.asyncio
152+
async def test_conduct_exit_interview():
153+
"""Test conducting an exit interview."""
154+
result = await conduct_exit_interview("John Doe")
155+
assert "##### Exit Interview Conducted" in result
156+
assert "**Employee Name:** John Doe" in result
157+
158+
159+
@pytest.mark.asyncio
160+
async def test_verify_employment():
161+
"""Test verifying employment."""
162+
result = await verify_employment("John Doe")
163+
assert "##### Employment Verification" in result
164+
assert "**Employee Name:** John Doe" in result
165+
166+
167+
@pytest.mark.asyncio
168+
async def test_schedule_performance_review():
169+
"""Test scheduling a performance review."""
170+
result = await schedule_performance_review("John Doe", "2025-04-15")
171+
assert "##### Performance Review Scheduled" in result
172+
assert "**Date:** 2025-04-15" in result
173+
174+
175+
@pytest.mark.asyncio
176+
async def test_approve_expense_claim():
177+
"""Test approving an expense claim."""
178+
result = await approve_expense_claim("John Doe", 500.75)
179+
assert "##### Expense Claim Approved" in result
180+
assert "**Claim Amount:** $500.75" in result
181+
182+
183+
@pytest.mark.asyncio
184+
async def test_send_company_announcement():
185+
"""Test sending a company-wide announcement."""
186+
result = await send_company_announcement(
187+
"Holiday Schedule", "We will be closed on Christmas."
188+
)
189+
assert "##### Company Announcement" in result
190+
assert "**Subject:** Holiday Schedule" in result
191+
assert "We will be closed on Christmas." in result
192+
193+
194+
@pytest.mark.asyncio
195+
async def test_fetch_employee_directory():
196+
"""Test fetching the employee directory."""
197+
result = await fetch_employee_directory()
198+
assert "##### Employee Directory" in result
199+
200+
201+
@pytest.mark.asyncio
202+
async def test_initiate_background_check():
203+
"""Test initiating a background check."""
204+
result = await initiate_background_check("John Doe")
205+
assert "##### Background Check Initiated" in result
206+
assert "**Employee Name:** John Doe" in result
207+
208+
209+
@pytest.mark.asyncio
210+
async def test_organize_team_building_activity():
211+
"""Test organizing a team-building activity."""
212+
result = await organize_team_building_activity("Escape Room", "2025-05-01")
213+
assert "##### Team-Building Activity Organized" in result
214+
assert "**Activity Name:** Escape Room" in result
215+
216+
217+
@pytest.mark.asyncio
218+
async def test_manage_employee_transfer():
219+
"""Test managing an employee transfer."""
220+
result = await manage_employee_transfer("John Doe", "Marketing")
221+
assert "##### Employee Transfer" in result
222+
assert "**New Department:** Marketing" in result
223+
224+
225+
@pytest.mark.asyncio
226+
async def test_track_employee_attendance():
227+
"""Test tracking employee attendance."""
228+
result = await track_employee_attendance("John Doe")
229+
assert "##### Attendance Tracked" in result
230+
231+
232+
@pytest.mark.asyncio
233+
async def test_organize_health_and_wellness_program():
234+
"""Test organizing a health and wellness program."""
235+
result = await organize_health_and_wellness_program("Yoga Session", "2025-06-01")
236+
assert "##### Health and Wellness Program Organized" in result
237+
assert "**Program Name:** Yoga Session" in result
238+
239+
240+
@pytest.mark.asyncio
241+
async def test_facilitate_remote_work_setup():
242+
"""Test facilitating remote work setup."""
243+
result = await facilitate_remote_work_setup("John Doe")
244+
assert "##### Remote Work Setup Facilitated" in result
245+
assert "**Employee Name:** John Doe" in result
246+
247+
248+
@pytest.mark.asyncio
249+
async def test_manage_retirement_plan():
250+
"""Test managing a retirement plan."""
251+
result = await manage_retirement_plan("John Doe")
252+
assert "##### Retirement Plan Managed" in result
253+
assert "**Employee Name:** John Doe" in result

src/backend/tests/test_event_utils.py

Whitespace-only changes.

0 commit comments

Comments
 (0)