# Path: kibitzr/notifier/gotify.py
# class GotifyNotify(object):
#     def __init__(self, value):
#         import requests
#         self.session = requests.Session()
#         gotify_creds = settings().creds['gotify']
#         self.url = gotify_creds['url'].rstrip('/') + '/message'
#         self.token = gotify_creds['token']
#         self.verify = gotify_creds.get('verify', True)
#         if not self.verify:
#             # Since certificate validation was disabled, do not show the warning
#             urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
#         if value is None:
#             value = {}
#         self.title = value.get('title', 'kibitzr')
#         self.priority = value.get('priority', 4)
# 
#     def post(self, report):
#         logger.info("Executing Gotify notifier")
#         response = self.session.post(
#             url=self.url,
#             json=self.json(report),
#             params=self.params(),
#             verify=self.verify
#         )
#         logger.debug(response.text)
#         response.raise_for_status()
#         return response
#     __call__ = post
# 
#     def params(self):
#         return {
#             'token': self.token
#         }
# 
#     def json(self, report):
#         return {
#             'title': self.title,
#             'message': report,
#             'priority': self.priority
#         }
# 
# Path: tests/compat.py

# 
# Path: tests/helpers.py
# class SettingsMock(ReloadableSettings):
# 
#     def __init__(self):
#         self.checks = []
#         self.notifiers = {}
#         self.creds = {'pass': 'password'}
# 
#     @classmethod
#     def instance(cls):
#         ReloadableSettings._instance = cls()
#         return ReloadableSettings._instance
# 
#     @staticmethod
#     def dispose():
#         ReloadableSettings._instance = None


import pytest
from kibitzr.notifier.gotify import GotifyNotify
from ...compat import mock
from ...helpers import SettingsMock



@pytest.fixture()
def settings():
    """Override native settings singleton with empty one"""
    return SettingsMock.instance()


def test_gotify_sample(settings):
    settings.creds.update({
        'gotify': {
            'url': 'http://localhost:8080',
            'token': '123456',
        }
    })
    value = {}
    notify = GotifyNotify(value=value)

# Path: kibitzr/notifier/gotify.py
# class GotifyNotify(object):
#     def __init__(self, value):
#         import requests
#         self.session = requests.Session()
#         gotify_creds = settings().creds['gotify']
#         self.url = gotify_creds['url'].rstrip('/') + '/message'
#         self.token = gotify_creds['token']
#         self.verify = gotify_creds.get('verify', True)
#         if not self.verify:
#             # Since certificate validation was disabled, do not show the warning
#             urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
#         if value is None:
#             value = {}
#         self.title = value.get('title', 'kibitzr')
#         self.priority = value.get('priority', 4)
# 
#     def post(self, report):
#         logger.info("Executing Gotify notifier")
#         response = self.session.post(
#             url=self.url,
#             json=self.json(report),
#             params=self.params(),
#             verify=self.verify
#         )
#         logger.debug(response.text)
#         response.raise_for_status()
#         return response
#     __call__ = post
# 
#     def params(self):
#         return {
#             'token': self.token
#         }
# 
#     def json(self, report):
#         return {
#             'title': self.title,
#             'message': report,
#             'priority': self.priority
#         }
# 
# Path: tests/compat.py

# 
# Path: tests/helpers.py
# class SettingsMock(ReloadableSettings):
# 
#     def __init__(self):
#         self.checks = []
#         self.notifiers = {}
#         self.creds = {'pass': 'password'}
# 
#     @classmethod
#     def instance(cls):
#         ReloadableSettings._instance = cls()
#         return ReloadableSettings._instance
# 
#     @staticmethod
#     def dispose():
#         ReloadableSettings._instance = None


# Path: tests/unit/notifiers/test_gotify.py
import pytest
from kibitzr.notifier.gotify import GotifyNotify
from ...compat import mock
from ...helpers import SettingsMock




@pytest.fixture()
def settings():
    """Override native settings singleton with empty one"""
    return SettingsMock.instance()


def test_gotify_sample(settings):
    settings.creds.update({
        'gotify': {
            'url': 'http://localhost:8080',
            'token': '123456',
        }
    })
    value = {}
    notify = GotifyNotify(value=value)

    with mock.patch.object(notify.session, 'post') as fake_post: