From cb014a9507ef98cf8dfa349d56b097a061e3438a Mon Sep 17 00:00:00 2001 From: Jannat Patel Date: Tue, 30 Dec 2025 10:40:26 +0530 Subject: [PATCH] test: certified participants with opportunities and hiring filters --- lms/lms/test_utils.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lms/lms/test_utils.py b/lms/lms/test_utils.py index b9aa1c94..c33c6fac 100644 --- a/lms/lms/test_utils.py +++ b/lms/lms/test_utils.py @@ -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):