tests.py 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. from django.test import TestCase
  2. from django.test import Client
  3. class SteamViewTestCase(TestCase):
  4. def testSteam(self):
  5. resp = self.client.get('/hackathon/steam/')
  6. self.assertEqual(resp.status_code, 200)
  7. def testSteamDiscountedGames(self):
  8. resp = self.client.get('/hackathon/steamDiscountedGames/')
  9. self.assertEqual(resp.status_code, 200)
  10. def testSteamPlaytimeForever(self):
  11. resp = self.client.get('/hackathon/steam/')
  12. for dict in resp.context:
  13. if 'playtime_forever' in dict:
  14. self.assertTrue('playtime_forever' in dict)
  15. def testSteamName(self):
  16. resp = self.client.get('/hackathon/steam/')
  17. for dict in resp.context:
  18. if 'name' in dict:
  19. self.assertTrue('name' in dict)
  20. def testSteamImg(self):
  21. resp = self.client.get('/hackathon/steam/')
  22. for dict in resp.context:
  23. if 'img_logo_url' in dict:
  24. self.assertTrue('img_logo_url' in dict)
  25. def testSteamAppID(self):
  26. resp = self.client.get('/hackathon/steam/')
  27. for dict in resp.context:
  28. if 'appid' in dict:
  29. self.assertTrue('appid' in dict)
  30. def testSteamDiscountedGamesDiscount(self):
  31. resp = self.client.get('/hackathon/steamDiscountedGames/')
  32. self.assertEqual(resp.context, None)
  33. class HackathonViewsTestCase(TestCase):
  34. def testIndex(self):
  35. resp = self.client.get('/hackathon/api/')
  36. self.assertEqual(resp.status_code, 200)
  37. def testQuandlDowJones(self):
  38. resp = self.client.get('/hackathon/quandlDowJones/')
  39. self.assertEqual(resp.status_code, 200)
  40. def testQuandlSnp500(self):
  41. resp = self.client.get('/hackathon/quandlSnp500/')
  42. self.assertEqual(resp.status_code, 200)
  43. def testQuandlNasdaq(self):
  44. resp = self.client.get('/hackathon/quandlNasdaq/')
  45. self.assertEqual(resp.status_code, 200)
  46. def testGithubUser(self):
  47. resp = self.client.get('/hackathon/githubUser/')
  48. self.assertEqual(resp.status_code, 200)
  49. def testGithubTopRepositories(self):
  50. resp = self.client.get('/hackathon/githubTopRepositories/')
  51. self.assertEqual(resp.status_code, 200)
  52. def testGithubResume(self):
  53. resp = self.client.get('/hackathon/githubResume/')
  54. self.assertEqual(resp.status_code, 200)
  55. def testTwilio(self):
  56. resp = self.client.get('/hackathon/twilio/')
  57. self.assertEqual(resp.status_code, 200)
  58. def testNytimespop(self):
  59. resp = self.client.get('/hackathon/nytimespop/')
  60. self.assertEqual(resp.status_code, 200)
  61. def testYelpPost(self):
  62. resp = self.client.post('/hackathon/yelp/', {'location': 'yelp-san-francisco'})
  63. self.assertEqual(resp.status_code, 200)
  64. def testYelpContent(self):
  65. resp = self.client.post('/hackathon/yelp/', {'location': 'yelp-san-francisco'})
  66. self.assertNotEqual(resp.content, '')