def test_query_construction(new_check, instance, filters, query): instance['filters'] = filters check = new_check(instance) check.load_configuration_models() assert construct_xpath_query( exclude_undefined_keys(check.config.filters.dict())) == query
def test_value_not_integer(self): with pytest.raises( Exception, match='Values for event filter `id` must be integers.'): construct_xpath_query({'id': ['foo']})
def test_unknown_value(self): with pytest.raises(Exception, match='Unknown value for event filter `type`: foo'): construct_xpath_query({'type': ['foo']})
def test_value_not_string(self): with pytest.raises( Exception, match='Values for event filter `type` must be strings.'): construct_xpath_query({'type': [0]})
def test_no_values(self): with pytest.raises(Exception, match='No values set for property filter: source'): construct_xpath_query({'source': []})
def test_unknown_filter(self): with pytest.raises(Exception, match='Unknown property filter: foo'): construct_xpath_query({'foo': 'bar'})
def test_query_construction(filters, query): assert construct_xpath_query(filters) == query