<commit_before>import datetime
import dateutil.tz
import pytest

from pattern_matcher.matcher import match

_observations = [
    {
        "type": "cybox-container",
        "objects": {
            "a0": {
                "type": "person",
                "name": "alice",
                "age": 10
            }
        }
    },
    {
        "type": "cybox-container",
        "objects": {
            "b0": {
                "type": "person",
                "name": "bob",
                "age": 17
            }
        }
    },
    {
        "type": "cybox-container",
        "objects": {
            "c0": {
                "type": "person",
                "name": "carol",
                "age": 22
            }
        }
    }
]

_timestamps = [datetime.datetime.now(dateutil.tz.tzutc())] * len(_observations)

@pytest.mark.parametrize("pattern", [
    "[person:name='alice'] and [person:age>20]",
    "[person:name='alice'] or [person:name='carol']",
    "[person:name='alice'] or [person:name='zed']",
    # tests operator precedence
    "[person:age > 20] or [person:name > 'zelda'] and [person:age < 0]"
])
def test_and_or_match(pattern):
    assert match(pattern, _observations, _timestamps, True)

@pytest.mark.parametrize("pattern", [
    "[person:name='alice'] and [person:name='zed']",
    "[person:name='mary'] or [person:name='zed']",
    "[person:age > 70] or [person:name > 'zelda'] and [person:name matches /^...?$/]"
])
def test_and_or_nomatch(pattern):
    assert not match(pattern, _observations, _timestamps)<commit_msg>Added some blank lines to satisfy pycodestyle.<commit_after>import datetime
import dateutil.tz
import pytest

from pattern_matcher.matcher import match

_observations = [
    {
        "type": "cybox-container",
        "objects": {
            "a0": {
                "type": "person",
                "name": "alice",
                "age": 10
            }
        }
    },
    {
        "type": "cybox-container",
        "objects": {
            "b0": {
                "type": "person",
                "name": "bob",
                "age": 17
            }
        }
    },
    {
        "type": "cybox-container",
        "objects": {
            "c0": {
                "type": "person",
                "name": "carol",
                "age": 22
            }
        }
    }
]

_timestamps = [datetime.datetime.now(dateutil.tz.tzutc())] * len(_observations)


@pytest.mark.parametrize("pattern", [
    "[person:name='alice'] and [person:age>20]",
    "[person:name='alice'] or [person:name='carol']",
    "[person:name='alice'] or [person:name='zed']",
    # tests operator precedence
    "[person:age > 20] or [person:name > 'zelda'] and [person:age < 0]"
])
def test_and_or_match(pattern):
    assert match(pattern, _observations, _timestamps, True)


@pytest.mark.parametrize("pattern", [
    "[person:name='alice'] and [person:name='zed']",
    "[person:name='mary'] or [person:name='zed']",
    "[person:age > 70] or [person:name > 'zelda'] and [person:name matches /^...?$/]"
])
def test_and_or_nomatch(pattern):
    assert not match(pattern, _observations, _timestamps)
{'fraction_non_alphanumeric': 0.1748964638419879, 'fraction_numerical': 0.010194329404268876, 'mean_word_length': 2.096646942800789, 'pattern_counts': {'":': 36, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3737834', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1015, 'n_words': 193}