Coverage for CIResults/tests/test_serializers.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-19 09:20 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-19 09:20 +0000
1from django.test import TestCase
3from CIResults.metrics import Rate
4from CIResults.serializers import RateSerializer
7class RateSerializerTests(TestCase):
8 def test_basic(self):
9 rate = Rate(count=5, total=10)
10 self.assertEqual(RateSerializer(rate).data,
11 {'count': 5, 'total': 10, 'percent': 50.0})
13 def test_empty(self):
14 rate = Rate(count=0, total=0)
15 self.assertEqual(RateSerializer(rate).data,
16 {'count': 0, 'total': 0, 'percent': 0.0})