test: certified participants with opportunities and hiring filters

This commit is contained in:
Jannat Patel
2025-12-30 10:40:26 +05:30
parent c241abb820
commit cb014a9507
+22 -1
View File
@@ -267,15 +267,36 @@ class TestUtils(UnitTestCase):
self.assertIsNone(is_certified(self.course.name))
frappe.session.user = "Administrator"
def test_certified_participants(self):
def test_certified_participants_with_category(self):
filters = {"category": "Utility Course"}
certified_participants = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants), 1)
self.assertEqual(certified_participants[0].member, self.student1.email)
filters = {"category": "Nonexistent Category"}
certified_participants_no_match = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants_no_match), 0)
def test_certified_participants_with_open_to_opportunities(self):
filters = {"open_to_opportunities": 1}
certified_participants_open_to_oppo = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants_open_to_oppo), 0)
frappe.db.set_value("User", self.student1.email, "open_to", "Opportunities")
certified_participants_open_to_oppo = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants_open_to_oppo), 1)
frappe.db.set_value("User", self.student1.email, "open_to", "")
def test_certified_participants_with_open_to_hiring(self):
filters = {"hiring": 1}
certified_participants_hiring = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants_hiring), 0)
frappe.db.set_value("User", self.student1.email, "open_to", "Hiring")
certified_participants_hiring = get_certified_participants(filters=filters)
self.assertEqual(len(certified_participants_hiring), 1)
frappe.db.set_value("User", self.student1.email, "open_to", "")
def test_rating_validation(self):
student3 = self.create_user("student3@example.com", "Emily", "Cooper", ["LMS Student"])
with self.assertRaises(frappe.exceptions.ValidationError):