Ejemplo n.º 1
0
 def setup(self, db):
     self.model = CourseDailyMetrics
     self.date_fields = set([
         'date_for',
         'created',
         'modified',
     ])
     self.expected_results_keys = set(
         [o.name for o in self.model._meta.fields])
     field_names = (o.name for o in self.model._meta.fields
                    if o.name not in self.date_fields)
     self.metrics = CourseDailyMetricsFactory()
     self.serializer = CourseDailyMetricsSerializer(instance=self.metrics)
Ejemplo n.º 2
0
 def test_average_progress_not_valid(self, average_progress):
     obj = CourseDailyMetricsFactory(average_progress=average_progress)
     serializer = CourseDailyMetricsSerializer(instance=obj)
     with pytest.raises(ValidationError):
         data = serializer.data
Ejemplo n.º 3
0
 def test_average_progress_valid(self, average_progress):
     obj = CourseDailyMetricsFactory(average_progress=average_progress)
     serializer = CourseDailyMetricsSerializer(instance=obj)
     check_val = Decimal(average_progress).quantize(Decimal('.00'))
     data = serializer.data
     assert data['average_progress'] == six.text_type(check_val)