Skip to content

Commit

Permalink
remove redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ofek committed May 19, 2021
1 parent acf874e commit 46443fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 81 deletions.
49 changes: 0 additions & 49 deletions win32_event_log/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,6 @@
pytestmark = [pytest.mark.unit]


def test_no_path(dd_run_check, new_check, instance):
del instance['path']
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)


def test_invalid_start_option(dd_run_check, new_check, instance):
instance['start'] = 'soon'
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)


def test_invalid_event_priority(dd_run_check, new_check, instance):
instance['event_priority'] = 'important'
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)


@pytest.mark.parametrize('option', ['included_messages', 'excluded_messages'])
def test_invalid_message_filter_regular_expression(dd_run_check, new_check, instance, option):
instance[option] = ['\\1']
Expand All @@ -40,28 +16,3 @@ def test_invalid_message_filter_regular_expression(dd_run_check, new_check, inst
match='Error compiling pattern for option `{}`: invalid group reference 1 at position 1'.format(option),
):
dd_run_check(check)


def test_filters_not_map(dd_run_check, new_check, instance):
instance['filters'] = 'foo'
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)


def test_filter_value_not_array(dd_run_check, new_check, instance):
instance['filters'] = {'foo': 'bar'}
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)


def test_unknown_auth_type(dd_run_check, new_check, instance):
instance['server'] = 'foo'
instance['auth_type'] = 'foo'
check = new_check(instance)

with pytest.raises(Exception):
dd_run_check(check)
37 changes: 5 additions & 32 deletions win32_event_log/tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
pytestmark = [pytest.mark.unit]


def test_no_values():
with pytest.raises(Exception, match='No values set for property filter: source'):
construct_xpath_query({'source': []})


@pytest.mark.parametrize(
'filters, query',
[
Expand Down Expand Up @@ -50,35 +55,3 @@ def test_query_construction(new_check, instance, filters, query):
check.load_configuration_models()

assert construct_xpath_query(exclude_undefined_keys(check.config.filters.dict())) == query


class TestBasicValidation:
def test_unknown_filter(self):
with pytest.raises(Exception):
construct_xpath_query({'foo': 'bar'})

def test_no_values(self):
with pytest.raises(Exception, match='No values set for property filter: source'):
construct_xpath_query({'source': []})


class TestSourceValidation:
def test_value_not_string(self):
with pytest.raises(Exception):
construct_xpath_query({'source': [0]})


class TestTypeValidation:
def test_value_not_string(self):
with pytest.raises(Exception):
construct_xpath_query({'type': [0]})

def test_unknown_value(self):
with pytest.raises(Exception):
construct_xpath_query({'type': ['foo']})


class TestIdValidation:
def test_value_not_integer(self):
with pytest.raises(Exception):
construct_xpath_query({'id': ['foo']})

0 comments on commit 46443fa

Please sign in to comment.