<commit_before>import pytest

from notifiers import get_notifier
from notifiers.exceptions import BadArguments


class TestPushover(object):
    """Pushover notifier tests

    Note: These tests assume correct environs set for NOTIFIERS_PUSHOVER_TOKEN and NOTIFIERS_PUSHOVER_USER
    """

    @pytest.mark.parametrize('data, message', [
        ({}, 'user'),
        ({'user': 'foo'}, 'message'),
        ({'user': 'foo', 'message': 'bla'}, 'token')
    ])
    def test_missing_required(self, data, message):
        p = get_notifier('pushover')
        data['env_prefix'] = 'test'
        with pytest.raises(BadArguments) as e:
            p.notify(**data)
        assert f'\'{message}\' is a required property' in e.value.message

    def test_pushover_restrictions(self):
        """Pushover specific API restrictions:

        Priority value 2
        """

    def test_sanity(self):
        """Successful pushover notification"""
        p = get_notifier('pushover')
        data = {'message': 'foo'}
        rsp = p.notify(**data)
        rsp.raise_on_errors()

    def test_all_options(self):
        """Use all available pushover options"""<commit_msg>Added more pushover tests<commit_after>import pytest

from notifiers import get_notifier
from notifiers.exceptions import BadArguments, NotificationError


class TestPushover(object):
    """Pushover notifier tests

    Note: These tests assume correct environs set for NOTIFIERS_PUSHOVER_TOKEN and NOTIFIERS_PUSHOVER_USER
    """

    @pytest.mark.parametrize('data, message', [
        ({}, 'user'),
        ({'user': 'foo'}, 'message'),
        ({'user': 'foo', 'message': 'bla'}, 'token')
    ])
    def test_missing_required(self, data, message):
        p = get_notifier('pushover')
        data['env_prefix'] = 'test'
        with pytest.raises(BadArguments) as e:
            p.notify(**data)
        assert f'\'{message}\' is a required property' in e.value.message

    @pytest.mark.parametrize('data, message', [
        ({}, 'expire'),
        ({'expire': 30}, 'retry'),
    ])
    @pytest.mark.online
    def test_pushover_priority_2_restrictions(self, data, message):
        """Pushover specific API restrictions when using priority 2"""
        p = get_notifier('pushover')
        base_data = {'message': 'foo',
                     'priority': 2}
        final_data = {**base_data, **data}
        rsp = p.notify(**final_data)
        with pytest.raises(NotificationError) as e:
            rsp.raise_on_errors()
        print(e.value.message)
        assert message in e.value.message

    @pytest.mark.online
    def test_sanity(self):
        """Successful pushover notification"""
        p = get_notifier('pushover')
        data = {'message': 'foo'}
        rsp = p.notify(**data)
        rsp.raise_on_errors()

    @pytest.mark.online
    def test_all_options(self):
        """Use all available pushover options"""
        p = get_notifier('pushover')
        data = {'message': 'foo',
                'title': 'title',
                'priority': 2,
                'url': 'http://foo.com',
                'url_title': 'url title',
                'sound': 'bike',
                'timestamp': 0,
                'retry': 30,
                'expire': 30,
                'callback': 'http://callback.com',
                'html': 1}
        rsp = p.notify(**data)
        rsp.raise_on_errors()
{'fraction_non_alphanumeric': 0.13749260792430515, 'fraction_numerical': 0.00384387936132466, 'mean_word_length': 2.438008130081301, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3289300', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1013, 'n_words': 240}