Example #1
0
 def test_tag_keys_dynamic_field_validation_success(self):
     """Test that tag keys are validated as fields."""
     tag_keys = ["valid_tag"]
     query_params = {"valid_tag": "value"}
     serializer = GCPFilterSerializer(data=query_params, tag_keys=tag_keys)
     self.assertTrue(serializer.is_valid())
Example #2
0
 def test_filter_params_invalid_fields(self):
     """Test parse of filter params for invalid fields."""
     filter_params = {"invalid": "param"}
     serializer = GCPFilterSerializer(data=filter_params)
     with self.assertRaises(serializers.ValidationError):
         serializer.is_valid(raise_exception=True)
Example #3
0
 def test_filter_params_invalid_limit_time_scope_resolution(self):
     """Test parse of filter params for invalid resolution time_scope_units."""
     filter_params = {"resolution": "monthly", "time_scope_value": "-10", "time_scope_units": "day"}
     serializer = GCPFilterSerializer(data=filter_params)
     with self.assertRaises(serializers.ValidationError):
         serializer.is_valid(raise_exception=True)
Example #4
0
 def test_parse_filter_params_no_time(self):
     """Test parse of a filter param no time filter."""
     filter_params = {"region": FAKE.word(), "account": FAKE.uuid4(), "service": FAKE.word()}
     serializer = GCPFilterSerializer(data=filter_params)
     self.assertTrue(serializer.is_valid())