# Path: api/tests/factories.py
# class FuzzyFloatRound(factory.fuzzy.FuzzyFloat):
# class AbstractLocationFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class ProjectFactory(AbstractLocationFactory):
#     class Meta:
# class StationFactory(AbstractLocationFactory):
#     class Meta:
# class AbstractMeteringFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class MeteringFactory(AbstractMeteringFactory):
#     class Meta:
# class MeteringHistoryFactory(AbstractMeteringFactory):
#     class Meta:
#     def __init__(self, *args, **kwargs):
#     def fuzz(self):
#     def position(self):
#     def password(self):
#     def create_logo(self, create, extracted, **kwargs):
#     DEFAULT_PASSWORD = 'very_dangerous_password'
# 
# Path: api/serializers.py
# class ProjectSerializer(serializers.ModelSerializer):
#     owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
# 
#     class Meta:
#         model = Project
#         fields = (
#             'name',
#             'slug',
#             'created',
#             'updated',
#             'website',
#             'description',
#             'logo',
#             'position',
#             'country',
#             'state',
#             'county',
#             'community',
#             'city',
#             'district',
#             'owner',
#         )
# 
# class StationSerializer(serializers.ModelSerializer):
#     owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
# 
#     class Meta:
#         model = Station
#         fields = (
#             'id',
#             'name',
#             'created',
#             'updated',
#             'type',
#             'notes',
#             'is_in_test_mode',
#             'altitude',
#             'position',
#             'country',
#             'state',
#             'county',
#             'community',
#             'city',
#             'district',
#             'owner',
#             'project',
#             'last_metering',
#         )
# 
# class MeteringSerializer(serializers.ModelSerializer):
#     pm01 = serializers.FloatField(default=None, write_only=True)
#     temp_out2 = serializers.FloatField(default=None, write_only=True)
#     temp_out3 = serializers.FloatField(default=None, write_only=True)
#     temp_int_air1 = serializers.FloatField(default=None, write_only=True)
#     hum_out2 = serializers.FloatField(default=None, write_only=True)
#     hum_out3 = serializers.FloatField(default=None, write_only=True)
#     hum_int_air1 = serializers.FloatField(default=None, write_only=True)
#     rssi = serializers.FloatField(default=None, write_only=True)
#     bpress_out1 = serializers.FloatField(default=None, write_only=True)
# 
#     class Meta:
#         model = Metering
#         fields = (
#             'station',
#             'created',
#             'pm01',
#             'pm25',
#             'pm10',
#             'temp_out1',
#             'temp_out2',
#             'temp_out3',
#             'temp_int_air1',
#             'hum_out1',
#             'hum_out2',
#             'hum_out3',
#             'hum_int_air1',
#             'rssi',
#             'bpress_out1',
#             'hw_id',
#         )


from django.contrib.gis.geos.point import Point
from rest_framework.reverse import reverse
from rest_framework.status import (
    HTTP_200_OK,
    HTTP_201_CREATED,
    HTTP_204_NO_CONTENT,
    HTTP_401_UNAUTHORIZED,
    HTTP_400_BAD_REQUEST,
    HTTP_404_NOT_FOUND,
    HTTP_403_FORBIDDEN
)
from rest_framework.test import APITestCase
from .factories import (
    Project,
    Station,
    ProjectFactory,
    UserFactory,
    StationFactory,
    MeteringFactory
)
from ..serializers import ProjectSerializer, StationSerializer, MeteringSerializer
                'in_bbox': '19, 49, 22, 52'
            }
        )
        self.assertEqual(2, len(api_response.data['results']))


class MeteringApiTests(UserAuthBase):
    def setUp(self):
        self.existing_project = ProjectFactory.create()
        self.existing_station = StationFactory.create(project=self.existing_project)
        self.metering = MeteringFactory.build(station=self.existing_station)
        self.metering_data = MeteringSerializer(self.metering).data
        self.metering_list_url = reverse('metering-list')
        return super(MeteringApiTests, self).setUp()

    def test_add_metering(self):
        # test cache key removal before add_metering
        self.assertEqual(self.existing_station.last_metering, MeteringSerializer(None).data)
        self.assertEqual(self.existing_station.metering_set.count(), 0)

        metering_data = self.metering_data.copy()
        metering_data['token'] = self.existing_station.token
        api_response = self.client.post(self.metering_list_url, metering_data)

        self.assertEqual(api_response.status_code, HTTP_201_CREATED)
        self.assertEqual(self.existing_station.metering_set.count(), 1)

        # test cache key removal after add_metering
        self.assertEqual(
            self.existing_station.last_metering,

# Path: api/tests/factories.py
# class FuzzyFloatRound(factory.fuzzy.FuzzyFloat):
# class AbstractLocationFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class UserFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class ProjectFactory(AbstractLocationFactory):
#     class Meta:
# class StationFactory(AbstractLocationFactory):
#     class Meta:
# class AbstractMeteringFactory(factory.django.DjangoModelFactory):
#     class Meta:
# class MeteringFactory(AbstractMeteringFactory):
#     class Meta:
# class MeteringHistoryFactory(AbstractMeteringFactory):
#     class Meta:
#     def __init__(self, *args, **kwargs):
#     def fuzz(self):
#     def position(self):
#     def password(self):
#     def create_logo(self, create, extracted, **kwargs):
#     DEFAULT_PASSWORD = 'very_dangerous_password'
# 
# Path: api/serializers.py
# class ProjectSerializer(serializers.ModelSerializer):
#     owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
# 
#     class Meta:
#         model = Project
#         fields = (
#             'name',
#             'slug',
#             'created',
#             'updated',
#             'website',
#             'description',
#             'logo',
#             'position',
#             'country',
#             'state',
#             'county',
#             'community',
#             'city',
#             'district',
#             'owner',
#         )
# 
# class StationSerializer(serializers.ModelSerializer):
#     owner = serializers.HiddenField(default=serializers.CurrentUserDefault())
# 
#     class Meta:
#         model = Station
#         fields = (
#             'id',
#             'name',
#             'created',
#             'updated',
#             'type',
#             'notes',
#             'is_in_test_mode',
#             'altitude',
#             'position',
#             'country',
#             'state',
#             'county',
#             'community',
#             'city',
#             'district',
#             'owner',
#             'project',
#             'last_metering',
#         )
# 
# class MeteringSerializer(serializers.ModelSerializer):
#     pm01 = serializers.FloatField(default=None, write_only=True)
#     temp_out2 = serializers.FloatField(default=None, write_only=True)
#     temp_out3 = serializers.FloatField(default=None, write_only=True)
#     temp_int_air1 = serializers.FloatField(default=None, write_only=True)
#     hum_out2 = serializers.FloatField(default=None, write_only=True)
#     hum_out3 = serializers.FloatField(default=None, write_only=True)
#     hum_int_air1 = serializers.FloatField(default=None, write_only=True)
#     rssi = serializers.FloatField(default=None, write_only=True)
#     bpress_out1 = serializers.FloatField(default=None, write_only=True)
# 
#     class Meta:
#         model = Metering
#         fields = (
#             'station',
#             'created',
#             'pm01',
#             'pm25',
#             'pm10',
#             'temp_out1',
#             'temp_out2',
#             'temp_out3',
#             'temp_int_air1',
#             'hum_out1',
#             'hum_out2',
#             'hum_out3',
#             'hum_int_air1',
#             'rssi',
#             'bpress_out1',
#             'hw_id',
#         )


# Path: api/tests/test_views.py
from django.contrib.gis.geos.point import Point
from rest_framework.reverse import reverse
from rest_framework.status import (
    HTTP_200_OK,
    HTTP_201_CREATED,
    HTTP_204_NO_CONTENT,
    HTTP_401_UNAUTHORIZED,
    HTTP_400_BAD_REQUEST,
    HTTP_404_NOT_FOUND,
    HTTP_403_FORBIDDEN
)
from rest_framework.test import APITestCase
from .factories import (
    Project,
    Station,
    ProjectFactory,
    UserFactory,
    StationFactory,
    MeteringFactory
)
from ..serializers import ProjectSerializer, StationSerializer, MeteringSerializer

                'in_bbox': '19, 49, 22, 52'
            }
        )
        self.assertEqual(2, len(api_response.data['results']))


class MeteringApiTests(UserAuthBase):
    def setUp(self):
        self.existing_project = ProjectFactory.create()
        self.existing_station = StationFactory.create(project=self.existing_project)
        self.metering = MeteringFactory.build(station=self.existing_station)
        self.metering_data = MeteringSerializer(self.metering).data
        self.metering_list_url = reverse('metering-list')
        return super(MeteringApiTests, self).setUp()

    def test_add_metering(self):
        # test cache key removal before add_metering
        self.assertEqual(self.existing_station.last_metering, MeteringSerializer(None).data)
        self.assertEqual(self.existing_station.metering_set.count(), 0)

        metering_data = self.metering_data.copy()
        metering_data['token'] = self.existing_station.token
        api_response = self.client.post(self.metering_list_url, metering_data)

        self.assertEqual(api_response.status_code, HTTP_201_CREATED)
        self.assertEqual(self.existing_station.metering_set.count(), 1)

        # test cache key removal after add_metering
        self.assertEqual(
            self.existing_station.last_metering,

            MeteringSerializer(self.existing_station.metering_set.first()).data