Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 14 commits
  • 17 files changed
  • 0 comments
  • 1 contributor
Mar 03, 2012
Paul Traylor Minor update to classifiers in setup.py 839589c
Paul Traylor Initial work converting .md to .rst
Sinc pypi expects rst, it would be better to use that for the readme
and changelog
a7053e8
Paul Traylor Update egg info 65ebf50
Mar 16, 2012
Paul Traylor Refactoring cleanup of options f6b6d48
Paul Traylor Add coalescing support 0b805d0
Paul Traylor Switch tox to use nose 8a947e5
Paul Traylor Include README in the manifest file da8062a
Apr 12, 2012
Paul Traylor Switch the warning to an info log for a missing ~/.gntp file
It's not a severe warning when there is not a ~/.gntp file since
the class provides reasonable defaults. I also don't want to set
the default warning level as high as ERROR in case there are
actual warnings that need to be printed out.
22d81e9
Jul 11, 2012
Paul Traylor Add note about sending icons with the notification. Fixes #24 ce2b77a
Paul Traylor Add attached image example to docs a409676
Aug 12, 2012
Paul Traylor CLI flags should take priority over config file
Switch to importing a RawConfigParser manually and use the regular gntp.notifier class instead of the gntp.config class so we can more easily ensure that cli arguments should take priority over the config file version.

Fixes #26
e177c37
Sep 03, 2012
Paul Traylor Testing Cleanup
- More explicitly check that we're really testing for True and not bool(x) == True
- Move our application name and note type to the GNTPTestCase() class to make our tests more uniform.
6bde5b7
Paul Traylor Fix missing CRLF when dealing with resources
When attaching resources, we need to make sure it 
ends with double CRLF.

Also some minor cleanup to avoid using reserved
words str and type

Fixes #27
0e8a6db
Paul Traylor Tagging version 0.8 a4c1c69
1  MANIFEST.in
... ... @@ -0,0 +1 @@
  1 +include README.rst
61 README.md
Source Rendered
... ... @@ -1,61 +0,0 @@
1   -# GNTP
2   -
3   -This is a Python library for working with the [Growl Notification Transport Protocol](http://www.growlforwindows.com/gfw/help/gntp.aspx)
4   -
5   -It should work as a dropin replacement for the older Python bindings
6   -
7   -
8   -## Installation
9   -You can install with pip
10   -
11   - $ pip install gntp
12   -
13   -then test the module
14   -
15   - $ python -m gntp.notifier
16   -
17   -## Simple Usage
18   -
19   -```python
20   -import gntp.notifier
21   -
22   -# Simple "fire and forget" notification
23   -gntp.notifier.mini("Here's a quick message")
24   -
25   -# More complete example
26   -growl = gntp.notifier.GrowlNotifier(
27   - applicationName = "My Application Name",
28   - notifications = ["New Updates","New Messages"],
29   - defaultNotifications = ["New Messages"],
30   - # hostname = "computer.example.com", # Defaults to localhost
31   - # password = "abc123" # Defaults to a blank password
32   -)
33   -growl.register()
34   -
35   -# Send one message
36   -growl.notify(
37   - noteType = "New Messages",
38   - title = "You have a new message",
39   - description = "A longer message description",
40   - icon = "http://example.com/icon.png",
41   - sticky = False,
42   - priority = 1,
43   -)
44   -
45   -# Try to send a different type of message
46   -# This one may fail since it is not in our list
47   -# of defaultNotifications
48   -growl.notify(
49   - noteType = "New Updates",
50   - title = "There is a new update to download",
51   - description = "A longer message description",
52   - icon = "http://example.com/icon.png",
53   - sticky = False,
54   - priority = -1,
55   -)
56   -
57   -```
58   -
59   -## Bugs
60   -
61   -[GitHub issue tracker](https://github.com/kfdm/gntp/issues)
103 README.rst
Source Rendered
... ... @@ -0,0 +1,103 @@
  1 +GNTP
  2 +====
  3 +
  4 +This is a Python library for working with the `Growl Notification
  5 +Transport Protocol <http://www.growlforwindows.com/gfw/help/gntp.aspx>`_
  6 +
  7 +It should work as a dropin replacement for the older Python bindings
  8 +
  9 +Installation
  10 +------------
  11 +
  12 +You can install with pip
  13 +
  14 +::
  15 +
  16 + $ pip install gntp
  17 +
  18 +then test the module
  19 +
  20 +::
  21 +
  22 + $ python -m gntp.notifier
  23 +
  24 +Simple Usage
  25 +------------
  26 +
  27 +::
  28 +
  29 + import gntp.notifier
  30 +
  31 + # Simple "fire and forget" notification
  32 + gntp.notifier.mini("Here's a quick message")
  33 +
  34 + # More complete example
  35 + growl = gntp.notifier.GrowlNotifier(
  36 + applicationName = "My Application Name",
  37 + notifications = ["New Updates","New Messages"],
  38 + defaultNotifications = ["New Messages"],
  39 + # hostname = "computer.example.com", # Defaults to localhost
  40 + # password = "abc123" # Defaults to a blank password
  41 + )
  42 + growl.register()
  43 +
  44 + # Send one message
  45 + growl.notify(
  46 + noteType = "New Messages",
  47 + title = "You have a new message",
  48 + description = "A longer message description",
  49 + icon = "http://example.com/icon.png",
  50 + sticky = False,
  51 + priority = 1,
  52 + )
  53 +
  54 + # Try to send a different type of message
  55 + # This one may fail since it is not in our list
  56 + # of defaultNotifications
  57 + growl.notify(
  58 + noteType = "New Updates",
  59 + title = "There is a new update to download",
  60 + description = "A longer message description",
  61 + icon = "http://example.com/icon.png",
  62 + sticky = False,
  63 + priority = -1,
  64 + )
  65 +
  66 +
  67 +URL based images do not work in the OSX version of
  68 +`growl <http://code.google.com/p/growl/issues/detail?id=423>`_ 1.4
  69 +You can send the image along with the notification to get around this.
  70 +
  71 +::
  72 +
  73 + image = open('/path/to/image.png').read()
  74 + growl.notify(
  75 + noteType = "New Messages",
  76 + title = "You have a new message",
  77 + description = "This time we embed the image",
  78 + icon = image,
  79 + )
  80 +
  81 +
  82 +Bugs
  83 +----
  84 +
  85 +`GitHub issue tracker <https://github.com/kfdm/gntp/issues>`_
  86 +
  87 +
  88 +Changelog
  89 +---------
  90 +
  91 +`v0.8 <https://github.com/kfdm/gntp/compare/v0.7...v0.8>`_
  92 + - Fix a bug where resource sections were missing a CRLF
  93 + - Fix a bug where the cli client was using config values over options
  94 + - Add support for coalescing
  95 +
  96 +`v0.7 <https://github.com/kfdm/gntp/compare/0.6...v0.7>`_
  97 + - Support for images
  98 + - Better test coverage support
  99 +
  100 +`0.6 <https://github.com/kfdm/gntp/compare/0.5...0.6>`_
  101 + - ConfigParser aware GrowlNotifier that reads settings from ~/.gntp
  102 +
  103 +
9 docs/index.rst
Source Rendered
@@ -81,6 +81,15 @@ Complete Example
81 81 priority = -1,
82 82 )
83 83
  84 + # Send the image with the growl notification
  85 + image = open('/path/to/icon.png').read()
  86 + growl.notify(
  87 + noteType = "New Messages",
  88 + title = "Now with icons",
  89 + description = "This time we attach the image",
  90 + icon = image,
  91 + )
  92 +
84 93 GNTP Configfile Example
85 94 -----------------------
86 95 .. autoclass:: gntp.config.GrowlNotifier
113 gntp.egg-info/PKG-INFO
... ... @@ -1,16 +1,121 @@
1 1 Metadata-Version: 1.0
2 2 Name: gntp
3   -Version: 0.7
  3 +Version: 0.8
4 4 Summary: Growl Notification Transport Protocol for Python
5 5 Home-page: http://github.com/kfdm/gntp/
6 6 Author: Paul Traylor
7 7 Author-email: UNKNOWN
8 8 License: UNKNOWN
9   -Description: UNKNOWN
  9 +Description: GNTP
  10 + ====
  11 +
  12 + This is a Python library for working with the `Growl Notification
  13 + Transport Protocol <http://www.growlforwindows.com/gfw/help/gntp.aspx>`_
  14 +
  15 + It should work as a dropin replacement for the older Python bindings
  16 +
  17 + Installation
  18 + ------------
  19 +
  20 + You can install with pip
  21 +
  22 + ::
  23 +
  24 + $ pip install gntp
  25 +
  26 + then test the module
  27 +
  28 + ::
  29 +
  30 + $ python -m gntp.notifier
  31 +
  32 + Simple Usage
  33 + ------------
  34 +
  35 + ::
  36 +
  37 + import gntp.notifier
  38 +
  39 + # Simple "fire and forget" notification
  40 + gntp.notifier.mini("Here's a quick message")
  41 +
  42 + # More complete example
  43 + growl = gntp.notifier.GrowlNotifier(
  44 + applicationName = "My Application Name",
  45 + notifications = ["New Updates","New Messages"],
  46 + defaultNotifications = ["New Messages"],
  47 + # hostname = "computer.example.com", # Defaults to localhost
  48 + # password = "abc123" # Defaults to a blank password
  49 + )
  50 + growl.register()
  51 +
  52 + # Send one message
  53 + growl.notify(
  54 + noteType = "New Messages",
  55 + title = "You have a new message",
  56 + description = "A longer message description",
  57 + icon = "http://example.com/icon.png",
  58 + sticky = False,
  59 + priority = 1,
  60 + )
  61 +
  62 + # Try to send a different type of message
  63 + # This one may fail since it is not in our list
  64 + # of defaultNotifications
  65 + growl.notify(
  66 + noteType = "New Updates",
  67 + title = "There is a new update to download",
  68 + description = "A longer message description",
  69 + icon = "http://example.com/icon.png",
  70 + sticky = False,
  71 + priority = -1,
  72 + )
  73 +
  74 +
  75 + URL based images do not work in the OSX version of
  76 + `growl <http://code.google.com/p/growl/issues/detail?id=423>`_ 1.4
  77 + You can send the image along with the notification to get around this.
  78 +
  79 + ::
  80 +
  81 + image = open('/path/to/image.png').read()
  82 + growl.notify(
  83 + noteType = "New Messages",
  84 + title = "You have a new message",
  85 + description = "This time we embed the image",
  86 + icon = image,
  87 + )
  88 +
  89 +
  90 + Bugs
  91 + ----
  92 +
  93 + `GitHub issue tracker <https://github.com/kfdm/gntp/issues>`_
  94 +
  95 +
  96 + Changelog
  97 + ---------
  98 +
  99 + `v0.8 <https://github.com/kfdm/gntp/compare/v0.7...v0.8>`_
  100 + - Fix a bug where resource sections were missing a CRLF
  101 + - Fix a bug where the cli client was using config values over options
  102 + - Add support for coalescing
  103 +
  104 + `v0.7 <https://github.com/kfdm/gntp/compare/0.6...v0.7>`_
  105 + - Support for images
  106 + - Better test coverage support
  107 +
  108 + `0.6 <https://github.com/kfdm/gntp/compare/0.5...0.6>`_
  109 + - ConfigParser aware GrowlNotifier that reads settings from ~/.gntp
  110 +
  111 +
  112 +
10 113 Platform: UNKNOWN
11 114 Classifier: Development Status :: 3 - Alpha
12 115 Classifier: Intended Audience :: Developers
13   -Classifier: Natural Language :: English
14 116 Classifier: License :: OSI Approved :: MIT License
15   -Classifier: Programming Language :: Python
  117 +Classifier: Natural Language :: English
16 118 Classifier: Operating System :: OS Independent
  119 +Classifier: Programming Language :: Python :: 2.5
  120 +Classifier: Programming Language :: Python :: 2.6
  121 +Classifier: Programming Language :: Python :: 2.7
2  gntp.egg-info/SOURCES.txt
... ... @@ -1,3 +1,5 @@
  1 +MANIFEST.in
  2 +README.rst
1 3 setup.py
2 4 gntp/__init__.py
3 5 gntp/cli.py
8 gntp/__init__.py
@@ -3,7 +3,7 @@
3 3 import time
4 4 import StringIO
5 5
6   -__version__ = '0.7'
  6 +__version__ = '0.8'
7 7
8 8 #GNTP/<version> <messagetype> <encryptionAlgorithmID>[:<ivValue>][ <keyHashAlgorithmID>:<keyHash>.<salt>]
9 9 GNTP_INFO_LINE = re.compile(
@@ -46,9 +46,9 @@ class UnsupportedError(BaseError):
46 46
47 47 class _GNTPBuffer(StringIO.StringIO):
48 48 """GNTP Buffer class"""
49   - def writefmt(self, str="", *args):
  49 + def writefmt(self, message="", *args):
50 50 """Shortcut function for writing GNTP Headers"""
51   - self.write((str % args).encode('utf8', 'replace'))
  51 + self.write((message % args).encode('utf8', 'replace'))
52 52 self.write(GNTP_EOL)
53 53
54 54
@@ -268,6 +268,7 @@ def encode(self):
268 268 buffer.writefmt()
269 269 buffer.write(data)
270 270 buffer.writefmt()
  271 + buffer.writefmt()
271 272
272 273 return buffer.getvalue()
273 274
@@ -371,6 +372,7 @@ def encode(self):
371 372 buffer.writefmt()
372 373 buffer.write(data)
373 374 buffer.writefmt()
  375 + buffer.writefmt()
374 376
375 377 return buffer.getvalue()
376 378
98 gntp/cli.py
... ... @@ -1,43 +1,76 @@
1 1 #!/usr/bin/env python
2 2
3 3 import sys
  4 +import os
4 5 import logging
5   -from gntp.config import GrowlNotifier
6   -from optparse import OptionParser
  6 +from gntp import __version__
  7 +from gntp.notifier import GrowlNotifier
  8 +from optparse import OptionParser, OptionGroup
  9 +from ConfigParser import RawConfigParser
  10 +
  11 +DEFAULT_CONFIG = os.path.expanduser('~/.gntp')
  12 +
  13 +config = RawConfigParser({
  14 + 'hostname': 'localhost',
  15 + 'password': None,
  16 + 'port': 23053,
  17 +})
  18 +config.read([DEFAULT_CONFIG])
  19 +if not config.has_section('gntp'):
  20 + logging.info('Error reading ~/.gntp config file')
  21 + config.add_section('gntp')
7 22
8 23
9 24 class ClientParser(OptionParser):
10 25 def __init__(self):
11   - OptionParser.__init__(self)
12   -
13   - #Network
14   - self.add_option("-H", "--host", help="Specify a hostname to which to send a remote notification. [%default]",
15   - dest="host", default='localhost')
16   - self.add_option("--port", help="port to listen on",
17   - dest="port", type="int", default=23053)
18   - self.add_option("-P", "--password", help="Network password",
19   - dest='password', default='')
20   -
21   - #Required (Needs Defaults)
22   - self.add_option("-n", "--name", help="Set the name of the application [%default]",
23   - dest="app", default='Python GNTP Test Client')
24   - self.add_option("-N", "--notification", help="Set the notification name [%default]",
25   - dest="name", default='Notification')
26   - self.add_option("-t", "--title", help="Set the title of the notification [Default :%default]",
27   - dest="title", default=None)
28   - self.add_option("-m", "--message", help="Sets the message instead of using stdin",
29   - dest="message", default=None)
30   -
31   - #Optional (Does not require Default)
32   - self.add_option('-v', '--verbose', help="Verbosity levels",
33   - dest='verbose', action='count', default=0)
34   - self.add_option("-s", "--sticky", help="Make the notification sticky [%default]",
35   - dest='sticky', action="store_true", default=False)
36   - self.add_option("-p", "--priority", help="-2 to 2 [%default]",
37   - dest="priority", type="int", default=0)
38   - self.add_option("--image", help="Icon for notification (Only supports URL currently)",
39   - dest="icon", default=None)
40   - self.add_option("--callback", help="URL callback", dest="callback")
  26 + OptionParser.__init__(self, version="%%prog %s" % __version__)
  27 +
  28 + group = OptionGroup(self, "Network Options")
  29 + group.add_option("-H", "--host",
  30 + dest="host", default=config.get('gntp', 'hostname'),
  31 + help="Specify a hostname to which to send a remote notification. [%default]")
  32 + group.add_option("--port",
  33 + dest="port", default=config.getint('gntp', 'port'), type="int",
  34 + help="port to listen on [%default]")
  35 + group.add_option("-P", "--password",
  36 + dest='password', default=config.get('gntp', 'password'),
  37 + help="Network password")
  38 + self.add_option_group(group)
  39 +
  40 + group = OptionGroup(self, "Notification Options")
  41 + group.add_option("-n", "--name",
  42 + dest="app", default='Python GNTP Test Client',
  43 + help="Set the name of the application [%default]")
  44 + group.add_option("-s", "--sticky",
  45 + dest='sticky', default=False, action="store_true",
  46 + help="Make the notification sticky [%default]")
  47 + group.add_option("--image",
  48 + dest="icon", default=None,
  49 + help="Icon for notification (URL or /path/to/file)")
  50 + group.add_option("-m", "--message",
  51 + dest="message", default=None,
  52 + help="Sets the message instead of using stdin")
  53 + group.add_option("-p", "--priority",
  54 + dest="priority", default=0, type="int",
  55 + help="-2 to 2 [%default]")
  56 + group.add_option("-d", "--identifier",
  57 + dest="identifier",
  58 + help="Identifier for coalescing")
  59 + group.add_option("-t", "--title",
  60 + dest="title", default=None,
  61 + help="Set the title of the notification [%default]")
  62 + group.add_option("-N", "--notification",
  63 + dest="name", default='Notification',
  64 + help="Set the notification name [%default]")
  65 + group.add_option("--callback",
  66 + dest="callback",
  67 + help="URL callback")
  68 + self.add_option_group(group)
  69 +
  70 + # Extra Options
  71 + self.add_option('-v', '--verbose',
  72 + dest='verbose', default=0, action='count',
  73 + help="Verbosity levels")
41 74
42 75 def parse_args(self, args=None, values=None):
43 76 values, args = OptionParser.parse_args(self, args, values)
@@ -96,6 +129,7 @@ def main():
96 129 sticky=options.sticky,
97 130 priority=options.priority,
98 131 callback=options.callback,
  132 + identifier=options.identifier,
99 133 )
100 134 if result is not True:
101 135 exit(result)
5 gntp/config.py
@@ -24,7 +24,7 @@
24 24 def mini(description, applicationName='PythonMini', noteType="Message",
25 25 title="Mini Message", applicationIcon=None, hostname='localhost',
26 26 password=None, port=23053, sticky=False, priority=None,
27   - callback=None, notificationIcon=None):
  27 + callback=None, notificationIcon=None, identifier=None):
28 28 """Single notification function
29 29
30 30 Simple notification function in one line. Has only one required parameter
@@ -52,6 +52,7 @@ def mini(description, applicationName='PythonMini', noteType="Message",
52 52 sticky=sticky,
53 53 priority=priority,
54 54 callback=callback,
  55 + identifier=identifier,
55 56 )
56 57
57 58
@@ -85,7 +86,7 @@ def __init__(self, applicationName='Python GNTP', notifications=[],
85 86 # saving the config, it should be safe to just add it here so the
86 87 # code below doesn't complain
87 88 if not config.has_section('gntp'):
88   - logger.warning('No [gntp] section found in ~/.gntp config file')
  89 + logger.info('Error reading ~/.gntp config file')
89 90 config.add_section('gntp')
90 91
91 92 self.applicationName = applicationName
11 gntp/notifier.py
@@ -25,7 +25,7 @@
25 25 def mini(description, applicationName='PythonMini', noteType="Message",
26 26 title="Mini Message", applicationIcon=None, hostname='localhost',
27 27 password=None, port=23053, sticky=False, priority=None,
28   - callback=None, notificationIcon=None):
  28 + callback=None, notificationIcon=None, identifier=None):
29 29 """Single notification function
30 30
31 31 Simple notification function in one line. Has only one required parameter
@@ -57,6 +57,7 @@ def mini(description, applicationName='PythonMini', noteType="Message",
57 57 sticky=sticky,
58 58 priority=priority,
59 59 callback=callback,
  60 + identifier=identifier,
60 61 )
61 62
62 63
@@ -127,7 +128,7 @@ def register(self):
127 128 return self._send('register', register)
128 129
129 130 def notify(self, noteType, title, description, icon=None, sticky=False,
130   - priority=None, callback=None):
  131 + priority=None, callback=None, identifier=None):
131 132 """Send a GNTP notifications
132 133
133 134 .. warning::
@@ -168,6 +169,8 @@ def notify(self, noteType, title, description, icon=None, sticky=False,
168 169 notice.add_header('Notification-Text', description)
169 170 if callback:
170 171 notice.add_header('Notification-Callback-Target', callback)
  172 + if identifier:
  173 + notice.add_header('Notification-Coalescing-ID', identifier)
171 174
172 175 self.add_origin_info(notice)
173 176 self.notify_hook(notice)
@@ -205,7 +208,7 @@ def notify_hook(self, packet):
205 208 def subscribe_hook(self, packet):
206 209 pass
207 210
208   - def _send(self, type, packet):
  211 + def _send(self, messagetype, packet):
209 212 """Send the GNTP Packet"""
210 213
211 214 packet.validate()
@@ -225,7 +228,7 @@ def _send(self, type, packet):
225 228
226 229 logger.debug('From : %s:%s <%s>\n%s', self.hostname, self.port, response.__class__, response)
227 230
228   - if response.info['messagetype'] == '-OK':
  231 + if type(response) == gntp.GNTPOK:
229 232 return True
230 233 logger.error('Invalid response: %s', response.error())
231 234 return response.error()
11 gntp/test/__init__.py
@@ -3,14 +3,17 @@
3 3
4 4
5 5 class GNTPTestCase(unittest.TestCase):
  6 + application = 'GNTP unittest'
  7 + notification_name = 'Testing'
  8 +
6 9 notification = {
7   - 'noteType': 'Testing',
  10 + 'noteType': notification_name,
8 11 'title': 'Unittest Title',
9 12 'description': 'Unittest Description',
10 13 }
11 14
12 15 def setUp(self):
13   - self.growl = GrowlNotifier('GNTP unittest', ['Testing'])
  16 + self.growl = GrowlNotifier(self.application, [self.notification_name])
14 17 self.growl.register()
15 18
16 19 def _notify(self, **kargs):
@@ -19,3 +22,7 @@ def _notify(self, **kargs):
19 22 kargs[k] = self.notification[k]
20 23
21 24 return self.growl.notify(**kargs)
  25 +
  26 + def assertIsTrue(self, result):
  27 + """Python 2.5 safe way to assert that the result is true"""
  28 + return self.assertEqual(result, True)
21 gntp/test/basic_tests.py
@@ -11,7 +11,6 @@
11 11 import gntp.config
12 12 import gntp.notifier
13 13
14   -APPLICATION_NAME = "GNTP unittest"
15 14 ICON_URL = "https://www.google.com/intl/en_com/images/srpr/logo3w.png"
16 15 ICON_FILE = os.path.join(os.path.dirname(__file__), "growl-icon.png")
17 16 CALLBACK_URL = "http://github.com"
@@ -20,32 +19,32 @@
20 19 class BasicTests(GNTPTestCase):
21 20 def test_mini(self):
22 21 gntp.notifier.mini('Testing gntp.notifier.mini',
23   - applicationName=APPLICATION_NAME
  22 + applicationName=self.application
24 23 )
25 24
26 25 def test_config(self):
27 26 gntp.config.mini('Testing gntp.config.mini',
28   - applicationName=APPLICATION_NAME
  27 + applicationName=self.application
29 28 )
30 29
31 30 def test_priority(self):
32 31 for priority in [2, 1, 0, -1, -2]:
33   - self.assertTrue(self._notify(
  32 + self.assertIsTrue(self._notify(
34 33 description='Priority %s' % priority,
35 34 priority=priority
36 35 ))
37 36
38 37 def test_english(self):
39   - self.assertTrue(self._notify(description='Hello World'))
  38 + self.assertIsTrue(self._notify(description='Hello World'))
40 39
41 40 def test_extra(self):
42   - self.assertTrue(self._notify(description='allô'))
  41 + self.assertIsTrue(self._notify(description='allô'))
43 42
44 43 def test_japanese(self):
45   - self.assertTrue(self._notify(description='おはおう'))
  44 + self.assertIsTrue(self._notify(description='おはおう'))
46 45
47 46 def test_sticky(self):
48   - self.assertTrue(self._notify(sticky=True, description='Sticky Test'))
  47 + self.assertIsTrue(self._notify(sticky=True, description='Sticky Test'))
49 48
50 49 def test_unknown_note(self):
51 50 self.assertRaises(AssertionError, self._notify, noteType='Unknown')
@@ -54,19 +53,19 @@ def test_parse_error(self):
54 53 self.assertRaises(gntp.ParseError, gntp.parse_gntp, 'Invalid GNTP Packet')
55 54
56 55 def test_url_icon(self):
57   - self.assertTrue(self._notify(
  56 + self.assertIsTrue(self._notify(
58 57 icon=ICON_URL,
59 58 description='test_url_icon',
60 59 ))
61 60
62 61 def test_file_icon(self):
63   - self.assertTrue(self._notify(
  62 + self.assertIsTrue(self._notify(
64 63 icon=open(ICON_FILE).read(),
65 64 description='test_file_icon',
66 65 ))
67 66
68 67 def test_callback(self):
69   - self.assertTrue(self._notify(
  68 + self.assertIsTrue(self._notify(
70 69 callback=CALLBACK_URL,
71 70 description='Testing Callback',
72 71 ))
4 gntp/test/test_config.py
@@ -15,11 +15,11 @@ class ConfigTests(GNTPTestCase):
15 15 def setUp(self):
16 16 if os.path.exists(ORIGINAL_CONFIG):
17 17 os.rename(ORIGINAL_CONFIG, BACKUP_CONFIG)
18   - self.growl = GrowlNotifier('GNTP unittest', ['Testing'])
  18 + self.growl = GrowlNotifier(self.application, [self.notification_name])
19 19 self.growl.register()
20 20
21 21 def test_missing_config(self):
22   - self.assertTrue(self._notify(description='No config file test'))
  22 + self.assertIsTrue(self._notify(description='No config file test'))
23 23
24 24 def tearDown(self):
25 25 if os.path.exists(BACKUP_CONFIG):
10 gntp/test/test_hash.py
@@ -24,19 +24,19 @@ def test_config(self):
24 24 password to test with, so our password hash is no good
25 25 """
26 26 config = os.path.expanduser('~/.gntp')
27   - self.assertTrue(os.path.exists(config))
  27 + self.assertIsTrue(os.path.exists(config))
28 28
29 29 def test_md5(self):
30   - self.assertTrue(self._hash('MD5'))
  30 + self.assertIsTrue(self._hash('MD5'))
31 31
32 32 def test_sha1(self):
33   - self.assertTrue(self._hash('SHA1'))
  33 + self.assertIsTrue(self._hash('SHA1'))
34 34
35 35 def test_sha256(self):
36   - self.assertTrue(self._hash('SHA256'))
  36 + self.assertIsTrue(self._hash('SHA256'))
37 37
38 38 def test_sha512(self):
39   - self.assertTrue(self._hash('SHA512'))
  39 + self.assertIsTrue(self._hash('SHA512'))
40 40
41 41 def test_fake(self):
42 42 '''Fake hash should not work'''
37 gntp/test/test_resources.py
... ... @@ -0,0 +1,37 @@
  1 +# https://github.com/kfdm/gntp/issues/27
  2 +# nosetests -v gntp.test.test_resources:ResourceTest
  3 +
  4 +import os
  5 +from gntp.test import GNTPTestCase
  6 +import gntp
  7 +
  8 +ICON_FILE = os.path.join(os.path.dirname(__file__), "growl-icon.png")
  9 +ICON_DATA = open(ICON_FILE).read()
  10 +FILE_DATA = open(__file__).read()
  11 +
  12 +
  13 +class ResourceTest(GNTPTestCase):
  14 + def test_single_resource(self):
  15 + notification = gntp.GNTPNotice(
  16 + app=self.application,
  17 + name=self.notification_name,
  18 + title="Testing Single Resource",
  19 + password=self.growl.password,
  20 + )
  21 + resource = notification.add_resource(ICON_DATA)
  22 + notification.add_header('Notification-Icon', resource)
  23 + self.assertIsTrue(self.growl._send('notify', notification))
  24 +
  25 + def test_double_resource(self):
  26 + notification = gntp.GNTPNotice(
  27 + app=self.application,
  28 + name=self.notification_name,
  29 + title="Testing Double Resource",
  30 + password=self.growl.password,
  31 + )
  32 +
  33 + notification.add_resource(FILE_DATA)
  34 + resource = notification.add_resource(ICON_DATA)
  35 + notification.add_header('Notification-Icon', resource)
  36 +
  37 + self.assertIsTrue(self.growl._send('notify', notification))
9 setup.py
@@ -10,18 +10,21 @@
10 10 setup(
11 11 name='gntp',
12 12 description='Growl Notification Transport Protocol for Python',
  13 + long_description=open('README.rst').read(),
13 14 author='Paul Traylor',
14 15 url='http://github.com/kfdm/gntp/',
15 16 version=gntp.__version__,
16 17 packages=['gntp'],
17 18 # http://pypi.python.org/pypi?%3Aaction=list_classifiers
18   - classifiers = [
  19 + classifiers=[
19 20 'Development Status :: 3 - Alpha',
20 21 'Intended Audience :: Developers',
21   - 'Natural Language :: English',
22 22 'License :: OSI Approved :: MIT License',
23   - 'Programming Language :: Python',
  23 + 'Natural Language :: English',
24 24 'Operating System :: OS Independent',
  25 + 'Programming Language :: Python :: 2.5',
  26 + 'Programming Language :: Python :: 2.6',
  27 + 'Programming Language :: Python :: 2.7',
25 28 ],
26 29 entry_points={
27 30 'console_scripts': [
4 tox.ini
@@ -2,5 +2,5 @@
2 2 [tox]
3 3 envlist = py25,py26,py27
4 4 [testenv]
5   -deps=pytest # install pytest in the venvs
6   -commands=py.test # or 'nosetests' or ...
  5 +deps=nose # install pytest in the venvs
  6 +commands=nosetests # or 'nosetests' or ...

No commit comments for this range

Something went wrong with that request. Please try again.