Commits

Jeffrey Goettsch committed 51f5434

Added tests for the add_key method.

Comments (0)

Files changed (1)

pushnotify/tests/tests.py

 import os
 import unittest
 
+from pushnotify import abstract
 from pushnotify import get_client
 from pushnotify import exceptions
 from pushnotify import nma
     from pushnotify.tests.pushoverkeys import USER as PUSHOVER_USER
 
 
+class AbstractClientTest(unittest.TestCase):
+    """Test the AbstractClient class.
+
+    """
+
+    def setUp(self):
+
+        self.client = abstract.AbstractClient()
+
+    def test_add_key_apikey(self):
+        """Test the add_key method with an apikey.
+
+        """
+
+        apikey = 'foo'
+        self.assertTrue(apikey not in self.client.apikeys.keys())
+
+        self.client.add_key(apikey)
+        self.assertTrue(apikey in self.client.apikeys.keys())
+
+    def test_add_key_device_key(self):
+        """Test the add_key method with a device_key.
+
+        """
+
+        apikey = 'foo'
+        self.client.add_key('foo')
+
+        device_key = 'bar'
+        self.assertTrue(device_key not in self.client.apikeys[apikey])
+
+        self.client.add_key(apikey, device_key)
+        self.assertTrue(device_key in self.client.apikeys[apikey])
+
+
 class NMATest(unittest.TestCase):
     """Test the Notify my Android client.