Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- class TestGetWaiters(unittest.TestCase):
- def setUp(self):
- # Mock data for testing
- self.waiters = [
- {'name': 'John', 'total_earnings': 100},
- {'name': 'Alice', 'total_earnings': 200},
- {'name': 'Bob', 'total_earnings': 150},
- {'name': 'Eve', 'total_earnings': 300}
- ]
- self.test_object = YourClass(self.waiters) # Replace YourClass with your actual class name
- def test_no_filter(self):
- # Test when no filter is applied
- result = self.test_object.get_waiters()
- self.assertEqual(len(result), 4) # Expecting all 4 waiters
- def test_min_earnings_filter(self):
- # Test when only min_earnings filter is applied
- result = self.test_object.get_waiters(min_earnings=150)
- self.assertEqual(len(result), 3) # Expecting 3 waiters with earnings >= 150
- def test_max_earnings_filter(self):
- # Test when only max_earnings filter is applied
- result = self.test_object.get_waiters(max_earnings=200)
- self.assertEqual(len(result), 3) # Expecting 3 waiters with earnings <= 200
- def test_both_filters(self):
- # Test when both min_earnings and max_earnings filters are applied
- result = self.test_object.get_waiters(min_earnings=150, max_earnings=250)
- self.assertEqual(len(result), 2) # Expecting 2 waiters with earnings between 150 and 250
- def test_invalid_filters(self):
- # Test when invalid filters are provided
- result = self.test_object.get_waiters(min_earnings=500, max_earnings=1000)
- self.assertEqual(len(result), 0) # Expecting no waiters as earnings range is invalid
- if __name__ == '__main__':
- unittest.main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement