def get_data(self): result = [] water = Meter.objects.filter(name="water") data = [ item for item in value_or_null(self.start_date, self.end_date, water, "date", "reading") ] result.append(data) gas = Meter.objects.filter(name="gas") data = [ item for item in value_or_null(self.start_date, self.end_date, gas, "date", "reading") ] result.append(data) return result
def test_generator_fills_middle_values_with_null(self): queryset = Meter.objects.filter(name="water") actual_data = [] for item in value_or_null(self.start_date, self.end_date, queryset, "date", "reading"): actual_data.append(item) expected_data = [10, 12, 13, 15, NULL, NULL, 16, 18, 20, 21] self.assertEqual(actual_data, expected_data)