def test_save(self): """Make sure we can save serializer data to the model """ assert SiteDailyMetrics.objects.count() == 1 data = dict(site=self.site, date_for='2020-01-01', cumulative_active_user_count=1, todays_active_user_count=2, total_user_count=3, course_count=4, total_enrollment_count=5) serializer = SiteDailyMetricsSerializer(data=data) assert serializer.is_valid() serializer.save() assert SiteDailyMetrics.objects.count() == 2
def setup(self, db): ''' ''' self.site = Site.objects.first() self.date_fields = set([ 'date_for', 'created', 'modified', ]) self.expected_results_keys = set( [o.name for o in SiteDailyMetrics._meta.fields]) self.site_daily_metrics = SiteDailyMetricsFactory() self.serializer = SiteDailyMetricsSerializer( instance=self.site_daily_metrics)