Skip to content

Commit

Permalink
Add some tests for adding a question
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjmcgrath committed Aug 23, 2015
1 parent 2e1e887 commit dbdcdf9
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
import json
import mock
import unittest
import webtest

import base
import helpers
import admin
import models


class AdminTestCase(base.TestCase):
Expand Down Expand Up @@ -88,5 +90,34 @@ def testPoseQuestionNoEmail(self):
self.assertEqual(0, len(messages))


def testAddQuestion(self):
helpers.user(email='foo@bar.com', is_trusted_tester=True).put()
os.environ['USER_IS_ADMIN'] = '1'
self.post('/admin/addquestion', params={
'answer': '/en/the_lost_boys',
'season': '1',
'week': '3',
'clues-0-image': webtest.Upload('screenshot.jpg', 'screenshot contents'),
'clues-1-text': 'clue 1',
'clues-2-text': 'clue 2',
'clues-3-text': 'clue 3',
'email_msg': 'My email message',
'imdb_url': 'http://www.imdb.com/title/foo/',
'packshot': webtest.Upload('packshot.jpg', 'packshot contents'),
}, headers={'host': 'ffcapp.appspot.com'})
question = models.Question.query().get()
season = models.Season.query().get()
clues = models.Clue.query().fetch(3)

self.assertEqual('The Lost Boys', question.answer_title)
self.assertEqual(1, season.number)
self.assertEqual(3, question.week)
self.assertIn('/_ah/img/encoded_gs_file:', question.packshot_url())
self.assertIn('/_ah/img/encoded_gs_file:', question.clue_image_url())
self.assertEquals(3, len(clues))
self.assertEquals('My email message', question.email_msg)
self.assertEquals('http://www.imdb.com/title/foo/', question.imdb_url)


if __name__ == '__main__':
unittest.main()

0 comments on commit dbdcdf9

Please sign in to comment.