def test_parse_filter_params_success(self): """Test parse of a filter param successfully.""" filter_params = { "resolution": "daily", "time_scope_value": "-10", "time_scope_units": "day", "resource_scope": [], } serializer = OCPAWSFilterSerializer(data=filter_params) self.assertTrue(serializer.is_valid())
def test_parse_filter_params_success(self): """Test parse of a filter param successfully.""" filter_params = { 'resolution': 'daily', 'time_scope_value': '-10', 'time_scope_units': 'day', 'resource_scope': [] } serializer = OCPAWSFilterSerializer(data=filter_params) self.assertTrue(serializer.is_valid())
def test_all_filter_op_fields(self): """Test that the allowed fields pass.""" for field in OCPAWSFilterSerializer._opfields: field = "and:" + field filter_param = {field: ["1", "2"]} serializer = OCPAWSFilterSerializer(data=filter_param) self.assertTrue(serializer.is_valid()) for field in OCPAWSFilterSerializer._opfields: field = "or:" + field filter_param = {field: ["1", "2"]} serializer = OCPAWSFilterSerializer(data=filter_param) self.assertTrue(serializer.is_valid())
def test_parse_filter_node(self): """Test filter by node.""" filter_params = {"node": ["*"]} serializer = OCPAWSFilterSerializer(data=filter_params) self.assertTrue(serializer.is_valid())
def test_parse_filter_cluster(self): """Test filter by cluster.""" filter_params = {"cluster": ["*"]} serializer = OCPAWSFilterSerializer(data=filter_params) self.assertTrue(serializer.is_valid())
def test_parse_filter_project(self): """Test filter by project.""" filter_params = {"project": ["*"]} serializer = OCPAWSFilterSerializer(data=filter_params) self.assertTrue(serializer.is_valid())