예제 #1
0
def test_format_filter_list_expected():
    filters = [{'a': ['<', 3]}]
    sampler = WMISampler(logger=None,
                         class_name='MyClass',
                         property_names='my.prop',
                         filters=filters)
    formatted_filters = sampler.formatted_filters
    assert formatted_filters == " WHERE ( a < '3' )"
예제 #2
0
def test_format_filter_like():
    filters = [{'a': '%foo'}]
    sampler = WMISampler(logger=None,
                         class_name='MyClass',
                         property_names='my.prop',
                         filters=filters)
    formatted_filters = sampler.formatted_filters
    assert formatted_filters == " WHERE ( a LIKE '%foo' )"
예제 #3
0
def test_format_filter_value():
    filters = [{'a': 'b'}, {'c': 'd'}]
    sampler = WMISampler(logger=None,
                         class_name='MyClass',
                         property_names='my.prop',
                         filters=filters)
    formatted_filters = sampler.formatted_filters
    assert formatted_filters == " WHERE ( c = 'd' ) OR ( a = 'b' )"
def test_format_filter_list():
    filters = [{'a': ['>', 1, 'i_get_ignored']}]
    sampler = WMISampler(logger=None,
                         class_name='MyClass',
                         property_names='my.prop',
                         filters=filters)
    formatted_filters = sampler.formatted_filters
    assert formatted_filters == " WHERE ( a > '1' )"
예제 #5
0
def test_format_filter_tuple():
    # needed for backwards compatibility and hardcoded filters
    filters = [{'a': ('<', 3)}]
    sampler = WMISampler(logger=None,
                         class_name='MyClass',
                         property_names='my.prop',
                         filters=filters)
    formatted_filters = sampler.formatted_filters
    assert formatted_filters == " WHERE ( a < '3' )"
예제 #6
0
def test_format_filter_win32_log():
    query = collections.OrderedDict(
        (
            ('TimeGenerated', ('>=', '202056101355.000000+')),
            ('Type', [('=', 'Warning'), ('=', 'Error')]),
            ('SourceName', [('=', 'MSSQLSERVER')]),
        )
    )

    sampler = WMISampler(logger=None, class_name='MyClass', property_names='my.prop', filters=[query])
    formatted_filters = sampler.formatted_filters
    assert (
        formatted_filters == " WHERE ( ( SourceName = 'MSSQLSERVER' ) "
        "AND ( Type = 'Warning' OR Type = 'Error' ) AND TimeGenerated >= '202056101355.000000+' )"
    )