pyruse/tests/filter_in.py

23 lines
809 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# pyruse is intended as a replacement to both fail2ban and epylog
# Copyright © 20172018 Y. Gablin
# Full licensing information in the LICENSE file, or gnu.org/licences/gpl-3.0.txt if the file is missing.
from pyruse.filters.filter_in import Filter
def whenNotInListThenFalse():
assert not Filter({"field": "v", "values": [0, "test"]}).filter({"v": 3})
def whenInListSameTypeThenTrue():
assert Filter({"field": "v", "values": [2]}).filter({"v": 2})
def whenInListDiffTypeThenTrue():
assert Filter({"field": "v", "values": [2.0]}).filter({"v": 2})
def whenNoFieldThenFalse():
assert not Filter({"field": "v", "values": [0]}).filter({"other": 0})
def unitTests():
whenNotInListThenFalse()
whenInListSameTypeThenTrue()
whenInListDiffTypeThenTrue()
whenNoFieldThenFalse()