Beispiel #1
0
    def test_get_rian_by_fields_one(self, ):

        field = Field(name="TEST")
        field.save()

        date_delta = timedelta(days=4)
        date = timezone.now() - date_delta

        Rain(field_owner=field, date=date, quantity=123).save()

        fields = get_rian_by_fields()

        assert len(fields) == 1
Beispiel #2
0
    def test_get_fields_by_rain_and_days_ok_two(self, ):
        field = Field(name="TEST")
        field.save()

        date_delta = timedelta(days=4)
        date = timezone.now() - date_delta

        Rain(field_owner=field, date=date, quantity=123).save()

        fields = get_fields_by_rain_and_days(days_ago_rain=7,
                                             rain_quantity=122)

        assert len(fields) == 1
Beispiel #3
0
    def test_filter_fields_by_rain_days_ago_ok_two(self, ):

        field = Field(name="TEST")
        field.save()

        date_delta = timedelta(days=10)
        date = timezone.now() - date_delta

        Rain(field_owner=field, date=date, quantity=123).save()

        fields = filter_fields_by_rain_days_ago(days_ago_rain=7)

        assert len(fields) == 0
Beispiel #4
0
    def test_get_fields_whit_rain_prom_ok_one(self, ):

        field = Field(name="TEST")
        field.save()

        date = timezone.now()

        Rain(field_owner=field, date=date, quantity=100).save()

        Rain(field_owner=field, date=date, quantity=200).save()

        fields = get_fields_whit_rain_prom()

        assert fields[0]['rain_quantity_average'] == 150.0
        assert len(fields) == 1
Beispiel #5
0
 def to_representation(self, instance: Field):
     data = super().to_representation(instance)
     data['farm'] = BaseFarmSerializer(instance.farm).data
     print(instance.latest_data())
     data['latest_data'] = DataSerializer(instance.latest_data()).data
     return data