def test_session_populates_form(self): utils.this_month() s = self.session s["name"] = 'Bob' s.save() response = self.client.get('/checkin/', follow=True) self.assertEqual(response.context['form']['name'].value(), 'Bob')
def test_create_qotm(self): m = utils.this_month() question = "What do you think about bikes?" q = models.QuestionOfTheMonth.objects.create(wr_day_month=m, value=question) self.assertEqual(q.wr_day_month, m) self.assertEqual(q.value, "What do you think about bikes?")
def test_current_month_question_shown(self): before = datetime.datetime.now() - datetime.timedelta(days=32) after = datetime.datetime.now() + datetime.timedelta(days=32) last_month = models.Month.objects.create( wr_day=before, open_checkin=before - datetime.timedelta(days=3), close_checkin=before + datetime.timedelta(days=3)) next_month = models.Month.objects.create( wr_day=after, open_checkin=after - datetime.timedelta(days=3), close_checkin=after + datetime.timedelta(days=3)) models.QuestionOfTheMonth.objects.create( wr_day_month=last_month, value='Why is transit important?') models.QuestionOfTheMonth.objects.create( wr_day_month=utils.this_month(), value='When will the DC Metro stop catching fire?') models.QuestionOfTheMonth.objects.create( wr_day_month=next_month, value='How many tradeoffs does the state DOT make when budgeting?') response = self.client.get('/checkin/', follow=True) self.assertContains(response, 'When will the DC Metro stop catching fire?')
def submitting_a_survey(self): utils.this_month() self.request = self.factory.post(reverse('commuterform'), follow=True) self.request.session = self.parent.session return self