import os import sys import unittest import keyHelper pwd = os.path.dirname(os.path.abspath(__file__)) # put apis in package path sys.path.insert(0, os.path.normpath(os.path.join(pwd, '../apis'))) import lastfm KEY = keyHelper.grabKey('lastfm', 'LASTFM_KEY') SECRET = keyHelper.grabKey('lastfm', 'LASTFM_SECRET', 'secret') class LastfmTest(unittest.TestCase): def setUp(self): pass """ Make sure count returns an int """ def test_count(self): count = lastfm.todaysCount(KEY) self.assertIsInstance(count, int) """ Ensure response has proper props """ def test_listens(self): listens = lastfm.retrieve(KEY) self.assertIsInstance(listens, list) def test_artists(self): artists = lastfm.topArtists(KEY, SECRET, '1month')
import os import sys import unittest import keyHelper pwd = os.path.dirname(os.path.abspath(__file__)) # put apis in package path sys.path.insert(0, os.path.normpath(os.path.join(pwd, '../apis'))) import rescuetime KEY = keyHelper.grabKey('rescuetime') class RescueTimeTest(unittest.TestCase): def setUp(self): pass """ Make sure the expected keys are there """ def test_productivityResponse(self): productivity = rescuetime.todaysProductivity(KEY, True) if any(productivity): self.assertEqual( productivity['row_headers'][1], "Time Spent (seconds)" ) self.assertEqual('row_headers' in productivity, True) self.assertEqual('rows' in productivity, True) """ Make sure the response is formatted to what will be outputted in the template
import os import sys import unittest import keyHelper pwd = os.path.dirname(os.path.abspath(__file__)) # put apis in package path sys.path.insert(0, os.path.normpath(os.path.join(pwd, '../apis'))) import foursquare KEY = keyHelper.grabKey('foursquare') class FoursquareTest(unittest.TestCase): def setUp(self): pass """ Make sure what we send to the template has the write keys and is of the right type """ def test_checkins(self): checkins = foursquare.retrieve(KEY) self.assertIn('data', checkins) self.assertIn('count', checkins) self.assertIsInstance(checkins['data'], list) self.assertIsInstance(checkins['count'], int) """ Ensure returns an int """ def test_count(self):