Ejemplo n.º 1
0
    def test_get_count_view(self):
        team_temp = SurveyFactory()
        existing_response1 = ResponseFactory(collector=team_temp.current())
        existing_response2 = ResponseFactory(collector=team_temp.current())

        response = self.client.get(reverse('word_count', args=[str(team_temp.id)]))
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'word')
        self.assertContains(response, '2')
Ejemplo n.º 2
0
    def test_stats_count(self):
        team_temp = SurveyFactory()
        collector = team_temp.current()

        self.assertEqual(collector.stats['count'], 0)

        ResponseFactory(collector=collector)
        self.assertEqual(collector.stats['count'], 1)

        ResponseFactory(collector=collector)
        ResponseFactory(collector=collector)
        self.assertEqual(collector.stats['count'], 3)
Ejemplo n.º 3
0
    def test_stats_average(self):
        team_temp = SurveyFactory()
        collector = team_temp.current()

        self.assertEqual(collector.stats['average'], 0)

        ResponseFactory(collector=collector, score=5)
        self.assertEqual(collector.stats['average'], 5.0)

        ResponseFactory(collector=collector, score=7)
        ResponseFactory(collector=collector, score=6)
        self.assertEqual(collector.stats['average'], 6.0)
Ejemplo n.º 4
0
    def test_get_temperature_with_previous_response_view(self, mock_session_id):
        responding_user = UserFactory(id=utils.random_string(8))
        mock_session_id.return_value = responding_user.id

        team_temp = SurveyFactory()
        existing_response = ResponseFactory(collector=team_temp.current(), responder=responding_user)

        response = self.client.get(reverse('temp', args=[str(team_temp.id)]))

        self.assertTemplateUsed(response, 'form.html')
        self.assertContains(response, 'Wordplay Time!')
        self.assertContains(response, existing_response.id)
Ejemplo n.º 5
0
    def test_stats_word(self):
        team_temp = SurveyFactory()
        collector = team_temp.current()

        self.assertEqual(len(collector.stats['words']), 0)

        ResponseFactory(collector=collector, word='first')

        self.assertEqual(len(collector.stats['words']), 1)

        ResponseFactory(collector=collector, word='second')
        ResponseFactory(collector=collector, word='third')
        self.assertEqual(len(collector.stats['words']), 3)
Ejemplo n.º 6
0
    def test_stats_average(self):
        team_temp = SurveyFactory()
        self.assertEqual(team_temp.stats['average'], 0)

        collector = team_temp.current()
        ResponseFactory(collector=collector, score=5)
        self.assertEqual(team_temp.stats['average'], 5)

        team_temp.current().close()
        team_temp.collector_set.create(open_date=datetime.date.today(), active=True)
        collector = team_temp.current()

        ResponseFactory(collector=collector, score=6)
        ResponseFactory(collector=collector, score=7)

        self.assertEqual(team_temp.stats['average'], (5 + 6.5) / 2)
Ejemplo n.º 7
0
    def test_stats_count(self):
        team_temp = SurveyFactory()
        self.assertEqual(team_temp.stats['count'], 0)

        collector = team_temp.current()
        ResponseFactory(collector=collector)
        self.assertEqual(team_temp.stats['count'], 1)

        team_temp.current().close()
        team_temp.collector_set.create(open_date=datetime.date.today(), active=True)
        collector = team_temp.current()

        ResponseFactory(collector=collector)
        ResponseFactory(collector=collector)

        # 1 response in first + 2 responses in second / two collectors
        # (1 + 2) / 2
        self.assertEqual(team_temp.stats['count'], 1.5)
Ejemplo n.º 8
0
    def test_stats_only_count_running_set(self):
        team_temp = SurveyFactory()
        self.assertEqual(team_temp.stats['average'], 0)

        collector = team_temp.current()
        ResponseFactory(collector=collector, score=10)

        self.assertEqual(team_temp.stats['average'], 10)


        # fudge dates a bit so the running set is ordered correctly
        last_week = datetime.date.today() - datetime.timedelta(days=7)
        collector.open_date = last_week
        collector.save()

        for x in range(1, 6):
            team_temp.current().close()
            team_temp.collector_set.create(open_date=last_week + datetime.timedelta(days=x), active=True)

        self.assertEqual(team_temp.stats['average'], 0)
Ejemplo n.º 9
0
    def test_has_up_to_five_in_running_set(self):
        team_temp = SurveyFactory()
        self.assertEqual(1, len(team_temp.running_set()))

        team_temp.current().close()
        team_temp.collector_set.create(open_date=datetime.date.today(), active=True)

        self.assertEqual(2, len(team_temp.running_set()))

        for x in range(1, 8):  # more than five
            team_temp.current().close()
            team_temp.collector_set.create(open_date=datetime.date.today(), active=True)

        self.assertEqual(5, len(team_temp.running_set()))
Ejemplo n.º 10
0
 def test_current_is_active(self):
     team_temp = SurveyFactory()
     self.assertTrue(team_temp.current().active)
Ejemplo n.º 11
0
 def test_closing_unsets_active_flag(self):
     collector = SurveyFactory().current()
     collector.close()
     self.assertFalse(collector.active)
Ejemplo n.º 12
0
 def test_closing_sets_close_date(self):
     collector = SurveyFactory().current()
     collector.close()
     self.assertIsNotNone(collector.close_date)
     self.assertEqual(collector.close_date, datetime.date.today())