Browse Source

Merged DrkSephy/django-hackathon-starter into default

Marco Quezada 10 years ago
parent
commit
8c6d8307ad
2 changed files with 40 additions and 11 deletions
  1. 36 8
      hackathon_starter/hackathon/tests.py
  2. 4 3
      hackathon_starter/hackathon/views.py

+ 36 - 8
hackathon_starter/hackathon/tests.py

@@ -1,18 +1,46 @@
 from django.test import TestCase
 
-# Create your tests here.
+class SteamViewTestCase(TestCase):
+	def testSteam(self):
+		resp = self.client.get('/hackathon/steam/')
+		self.assertEqual(resp.status_code, 200)
 
-class HackathonViewsTestCase(TestCase):
-	def testIndex(self):
-		resp = self.client.get('/hackathon/api/')
+	def testSteamDiscountedGames(self):
+		resp = self.client.get('/hackathon/steamDiscountedGames/')
 		self.assertEqual(resp.status_code, 200)
 
-	def testSteam(self):
-		resp = self.client.get('/hackathon/steam')
-		self.assertEqual(resp.status_code, 301)
+	def testSteamPlaytimeForever(self):
+		resp = self.client.get('/hackathon/steam/')
+		for dict in resp.context:
+			if 'playtime_forever' in dict:
+				self.assertTrue('playtime_forever' in dict)
 
-	def testSteamDiscountedGames(self):
+	def testSteamName(self):
+		resp = self.client.get('/hackathon/steam/')
+		for dict in resp.context:
+			if 'name' in dict:
+				self.assertTrue('name' in dict)
+
+	def testSteamImg(self):
+		resp = self.client.get('/hackathon/steam/')
+		for dict in resp.context:
+			if 'img_logo_url' in dict:
+				self.assertTrue('img_logo_url' in dict)
+
+	def testSteamAppID(self):
+		resp = self.client.get('/hackathon/steam/')
+		for dict in resp.context:
+			if 'appid' in dict:
+				self.assertTrue('appid' in dict)
+
+	def testSteamDiscountedGamesDiscount(self):
 		resp = self.client.get('/hackathon/steamDiscountedGames/')
+		self.assertEqual(resp.context, None)
+
+
+class HackathonViewsTestCase(TestCase):
+	def testIndex(self):
+		resp = self.client.get('/hackathon/api/')
 		self.assertEqual(resp.status_code, 200)
 
 	def testQuandlDowJones(self):

+ 4 - 3
hackathon_starter/hackathon/views.py

@@ -84,19 +84,20 @@ def facebook(request):
 
 def quandlDowJones(request):
     '''Returns JSON response about the latest dowjones index.'''
-    APIKEY = ' fANs6ykrCdAxas7zpMz7'
+    APIKEY = 'fANs6ykrCdAxas7zpMz7'
     parsedData = dowjonesIndustrialAvg(APIKEY)
+    print parsedData
     return JsonResponse({'data': parsedData})
 
 def quandlSnp500(request):
     '''Returns JSON response about the latest SNP 500 index.'''
-    APIKEY = ' fANs6ykrCdAxas7zpMz7'
+    APIKEY = 'fANs6ykrCdAxas7zpMz7'
     parsedData = snp500IndexPull(APIKEY)
     return JsonResponse({'data': parsedData})
 
 def quandlNasdaq(request):
     '''Returns JSON response about the latest nasdaq index.'''
-    APIKEY = ' fANs6ykrCdAxas7zpMz7'
+    APIKEY = 'fANs6ykrCdAxas7zpMz7'
     parsedData = nasdaqPull(APIKEY)
     return JsonResponse({'data': parsedData})