| 12345678910111213141516171819202122232425 |
- import unittest
- from src.utils.health_calculator import calculate_health
- class TestHealthCalculator(unittest.TestCase):
- def test_calculate_health(self):
- # Test case for a healthy battery
- current_measurements = [0.5, 0.5, 0.5] # Example current measurements
- expected_health = 100 # Expected health percentage
- self.assertEqual(calculate_health(current_measurements), expected_health)
- def test_calculate_health_low_capacity(self):
- # Test case for a battery with low capacity
- current_measurements = [0.1, 0.1, 0.1] # Example current measurements
- expected_health = 20 # Expected health percentage
- self.assertEqual(calculate_health(current_measurements), expected_health)
- def test_calculate_health_empty_measurements(self):
- # Test case for empty measurements
- current_measurements = []
- expected_health = 0 # Expected health percentage
- self.assertEqual(calculate_health(current_measurements), expected_health)
- if __name__ == '__main__':
- unittest.main()
|