-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
117 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
import pkg_resources | ||
__version__ = pkg_resources.get_distribution(__name__).version | ||
try: | ||
__version__ = pkg_resources.get_distribution(__name__).version | ||
except: | ||
__version__ = 'unknown' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
from os import devnull | ||
from unittest import TestCase, main | ||
from sys import version_info | ||
|
||
from mock import patch, mock_open | ||
|
||
from ntfy.cli import load_config, parser | ||
|
||
|
||
py = version_info.major | ||
|
||
class TestLoadConfig(TestCase): | ||
|
||
@patch('ntfy.cli.stderr') | ||
def test_default_config(self, *mocks): | ||
config = load_config(parser.parse_args(['-c', devnull, 'send', ''])) | ||
self.assertEqual(config, {'backends': ['default']}) | ||
|
||
@patch(('__builtin__' if py == 2 else 'builtins') +'.open', mock_open()) | ||
@patch('ntfy.cli.json.load', lambda x: {'backend': 'foobar'}) | ||
def test_backwards_compat(self, *mocks): | ||
config = load_config(parser.parse_args(['-c', devnull, 'send', ''])) | ||
self.assertIn('backends', config) | ||
self.assertEqual(config['backends'], ['foobar']) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from os import devnull | ||
from unittest import TestCase, main | ||
from sys import version_info | ||
|
||
from mock import patch, mock_open, MagicMock | ||
|
||
from ntfy.cli import main as ntfy_main | ||
|
||
|
||
py = version_info.major | ||
|
||
class TestIntegration(TestCase): | ||
@patch(('__builtin__' if py == 2 else 'builtins') +'.open', mock_open()) | ||
@patch('ntfy.cli.json.load') | ||
@patch('ntfy.backends.pushover.requests.post') | ||
def test_pushover(self, mock_jsonload, mock_post): | ||
mock_jsonload.return_value = { | ||
'backends': ['pushover'], | ||
'pushover': {'user_key': MagicMock()}, | ||
} | ||
ntfy_main(['send', 'foobar']) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |