# Path: ntfy/backends/pushjet.py
# def notify(title,
#            message,
#            secret,
#            endpoint=None,
#            level=3,
#            link=None,
#            retcode=None):
#     """
#     Required parameter:
#         * ``secret`` - The Pushjet service secret token, created with
#             http://docs.pushjet.io/docs/creating-a-new-service
# 
#     Optional parameters:
#         * ``endpoint`` - custom Pushjet API endpoint
#             (defaults to https://api.pushjet.io)
#         * ``level`` - The importance level from 1(low) to 5(high)
#         * ``link``
#     """
# 
#     data = {
#         'title': title,
#         'message': message,
#         'level': level,
#         'secret': secret,
#     }
# 
#     if link:
#         data['link'] = link
# 
#     headers = {'User-Agent': USER_AGENT}
# 
#     if endpoint is None:
#         endpoint = 'https://api.pushjet.io'
# 
#     resp = requests.post(endpoint + '/message', data=data, headers=headers)
# 
#     resp.raise_for_status()
# 
# Path: ntfy/config.py
# USER_AGENT = 'ntfy/{version} {default_user_agent}'.format(
#     version=__version__,
#     default_user_agent=requests.utils.default_user_agent())


from unittest import TestCase
from mock import patch
from ntfy.backends.pushjet import notify
from ntfy.config import USER_AGENT



class TestPushjet(TestCase):
    @patch('requests.post')
    def test_basic(self, mock_post):
        notify('title', 'message', secret='secret')
        mock_post.assert_called_once_with(
            'https://api.pushjet.io/message',
            data={
                'title': 'title',
                'message': 'message',
                'secret': 'secret',
                'level': 3
            },

# Path: ntfy/backends/pushjet.py
# def notify(title,
#            message,
#            secret,
#            endpoint=None,
#            level=3,
#            link=None,
#            retcode=None):
#     """
#     Required parameter:
#         * ``secret`` - The Pushjet service secret token, created with
#             http://docs.pushjet.io/docs/creating-a-new-service
# 
#     Optional parameters:
#         * ``endpoint`` - custom Pushjet API endpoint
#             (defaults to https://api.pushjet.io)
#         * ``level`` - The importance level from 1(low) to 5(high)
#         * ``link``
#     """
# 
#     data = {
#         'title': title,
#         'message': message,
#         'level': level,
#         'secret': secret,
#     }
# 
#     if link:
#         data['link'] = link
# 
#     headers = {'User-Agent': USER_AGENT}
# 
#     if endpoint is None:
#         endpoint = 'https://api.pushjet.io'
# 
#     resp = requests.post(endpoint + '/message', data=data, headers=headers)
# 
#     resp.raise_for_status()
# 
# Path: ntfy/config.py
# USER_AGENT = 'ntfy/{version} {default_user_agent}'.format(
#     version=__version__,
#     default_user_agent=requests.utils.default_user_agent())


# Path: tests/test_pushjet.py
from unittest import TestCase
from mock import patch
from ntfy.backends.pushjet import notify
from ntfy.config import USER_AGENT




class TestPushjet(TestCase):
    @patch('requests.post')
    def test_basic(self, mock_post):
        notify('title', 'message', secret='secret')
        mock_post.assert_called_once_with(
            'https://api.pushjet.io/message',
            data={
                'title': 'title',
                'message': 'message',
                'secret': 'secret',
                'level': 3
            },

            headers={'User-Agent': USER_AGENT})