Commits

Anonymous committed c916f76

Add test for auth and add

  • Participants
  • Parent commits f0b3f8a

Comments (0)

Files changed (3)

File readitlater/__init__.py

 import api
 
 API = api.API
-ReadItLaterError = ReadItLaterError
-RequestError = RequestError
-AuthError = AuthError
-RateLimitExceeded = RateLimitExceeded
-ServerError = ServerError
+ReadItLaterError = api.ReadItLaterError
+RequestError = api.RequestError
+AuthError = api.AuthError
+RateLimitExceeded = api.RateLimitExceeded
+ServerError = api.ServerError

File readitlater/api.py

     def add(self, username, password, url, title):
         self.__call('add', username=username, password=password,
                 url=url, title=title)
+        return True
 
     def status(self):
         if not self.__status:

File test_readitlater.py

 
 """Define test configurations in test_configs.py
 
-RIL_API_KEY = '<your api key>'"""
+RIL_APIKEY = '<your api key>'
+RIL_USERNAME = '<username>'
+RIL_PASSWORD = '<password>'
+"""
 
-class TestAuth(unittest.TestCase):
+class TestAPI(unittest.TestCase):
     def setUp(self):
-        self.ril = readitlater.API(configs.RIL_API_KEY)
+        self.api = readitlater.API(configs.RIL_APIKEY)
 
     def test_auth(self):
-        pass
+        self.assertRaises(readitlater.AuthError, self.api.auth, 'invalid_user', 'invalid_password')
+        self.assertTrue(self.api.auth(configs.RIL_USERNAME, configs.RIL_PASSWORD))
+
+    def test_add(self):
+        self.assertTrue(self.api.add(configs.RIL_USERNAME, configs.RIL_PASSWORD, 
+            'http://google.com/', 'Google'))
 
 if __name__ == '__main__':
     logging.basicConfig(level=logging.DEBUG, filename='test.log')
 
-    TEST_CASES = [
-            TestAuth,
-            ]
-    for test_cls in TEST_CASES:
-        testsuite = unittest.TestLoader().loadTestsFromTestCase(test_cls)
-        unittest.TextTestRunner(verbosity=2).run(testsuite)
+    testsuite = unittest.TestLoader().loadTestsFromTestCase(TestAPI)
+    unittest.TextTestRunner(verbosity=2).run(testsuite)