Esempio n. 1
0
    def test_optional_filter_params(self):
        """Min and max are optional"""
        del self.internal_filter['max']
        del self.external_filter['max']

        # Serialize
        result = serializers.FilterSerializer(self.internal_filter).data
        self.assertDictEqual(result, self.external_filter)

        # Deserialize
        serializer = serializers.FilterSerializer(data=self.external_filter)
        self.assertTrue(serializer.is_valid())
        self.assertDictEqual(serializer.validated_data, self.internal_filter)
Esempio n. 2
0
    def setUp(self):
        self.dimension = dimensions.get_dimension('time')
        self.dataset = corpus_models.Dataset.objects.create(
            name="test dataset", description='description')

        internal_filter = {
            'dimension': self.dimension,
            'min_time': now(),
            'max_time': now() + timedelta(minutes=5),
        }

        serialized_filter = serializers.FilterSerializer(internal_filter).data

        self.serialized_representation = {
            'dataset': self.dataset.id,
            'dimensions': [self.dimension.key],
            'filters': [serialized_filter],
        }

        # Should lookup exactly the same dimension
        self.deserialized_representation = {
            'dataset': self.dataset,
            'dimensions': [self.dimension],
            'filters': [internal_filter],
        }
Esempio n. 3
0
 def test_categorical_filter_deserialization(self):
     """Deserialization of an include list"""
     serializer = serializers.FilterSerializer(data=self.external_filter)
     self.assertTrue(serializer.is_valid())
     self.assertDictEqual(serializer.validated_data, self.internal_filter)
Esempio n. 4
0
 def test_categorical_filter_serialization(self):
     """Serialization of an include list"""
     result = serializers.FilterSerializer(self.internal_filter).data
     self.assertDictEqual(result, self.external_filter)
Esempio n. 5
0
 def test_time_filter_deserialization(self):
     """Deserialization of min and max filters"""
     serializer = serializers.FilterSerializer(data=self.external_filter)
     self.assertTrue(serializer.is_valid())
     self.assertDictEqual(serializer.validated_data, self.internal_filter)
Esempio n. 6
0
 def test_time_filter_serialization(self):
     """Serialization of min and max filters"""
     result = serializers.FilterSerializer(self.internal_filter).data
     self.assertDictEqual(result, self.external_filter)