Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
 def test_value_not_integer(self):
     with pytest.raises(
             Exception,
             match='Values for event filter `id` must be integers.'):
         construct_xpath_query({'id': ['foo']})
Ejemplo n.º 3
0
 def test_unknown_value(self):
     with pytest.raises(Exception,
                        match='Unknown value for event filter `type`: foo'):
         construct_xpath_query({'type': ['foo']})
Ejemplo n.º 4
0
 def test_value_not_string(self):
     with pytest.raises(
             Exception,
             match='Values for event filter `type` must be strings.'):
         construct_xpath_query({'type': [0]})
Ejemplo n.º 5
0
 def test_no_values(self):
     with pytest.raises(Exception,
                        match='No values set for property filter: source'):
         construct_xpath_query({'source': []})
Ejemplo n.º 6
0
 def test_unknown_filter(self):
     with pytest.raises(Exception, match='Unknown property filter: foo'):
         construct_xpath_query({'foo': 'bar'})
Ejemplo n.º 7
0
def test_query_construction(filters, query):
    assert construct_xpath_query(filters) == query