Пример #1
0
    def test_02_stats_hours(self):
        """Test STATS hours method works"""
        self.prepare_data()
        hour = str(datetime.datetime.utcnow().strftime('%H'))
        hours, hours_anon, hours_auth, max_hours,\
            max_hours_anon, max_hours_auth = stats.stats_hours(self.project.id)
        print(hours)
        for i in range(0, 24):
            # There should be only 8 answers at current hour
            if str(i).zfill(2) == hour:
                err_msg = "At time %s there should be 8 answers" \
                          "but there are %s" % (str(i).zfill(2),
                                                hours[str(i).zfill(2)])
                assert hours[str(i).zfill(2)] == 8, "There should be 8 answers"
            else:
                err_msg = "At time %s there should be 0 answers" \
                          "but there are %s" % (str(i).zfill(2),
                                                hours[str(i).zfill(2)])
                assert hours[str(i).zfill(2)] == 0, err_msg

            if str(i).zfill(2) == hour:
                tmp = (hours_anon[hour] + hours_auth[hour])
                assert tmp == 8, "There should be 8 answers"
            else:
                tmp = (hours_anon[str(i).zfill(2)] +
                       hours_auth[str(i).zfill(2)])
                assert tmp == 0, "There should be 0 answers"
        err_msg = "It should be 8, as all answers are submitted in the same hour"
        assert max_hours == 8, err_msg
        assert (max_hours_anon + max_hours_auth) == 8, err_msg
Пример #2
0
    def test_02_stats_hours(self):
        """Test STATS hours method works"""
        hour = unicode(datetime.datetime.utcnow().strftime('%H'))
        hours, hours_anon, hours_auth, max_hours,\
            max_hours_anon, max_hours_auth = stats.stats_hours(self.project.id)
        print hours
        for i in range(0, 24):
            # There should be only 8 answers at current hour
            if str(i).zfill(2) == hour:
                err_msg = "At time %s there should be 8 answers" \
                          "but there are %s" % (str(i).zfill(2),
                                                hours[str(i).zfill(2)])
                assert hours[str(i).zfill(2)] == 8, "There should be 8 answers"
            else:
                err_msg = "At time %s there should be 0 answers" \
                          "but there are %s" % (str(i).zfill(2),
                                                hours[str(i).zfill(2)])
                assert hours[str(i).zfill(2)] == 0, err_msg

            if str(i).zfill(2) == hour:
                tmp = (hours_anon[hour] + hours_auth[hour])
                assert tmp == 8, "There should be 8 answers"
            else:
                tmp = (hours_anon[str(i).zfill(2)] + hours_auth[str(i).zfill(2)])
                assert tmp == 0, "There should be 0 answers"
        err_msg = "It should be 8, as all answers are submitted in the same hour"
        assert max_hours == 8, err_msg
        assert (max_hours_anon + max_hours_auth) == 8, err_msg