def test_stats_dates_completed_tasks(self): """Test STATS stats_dates with tasks completed tasks""" today = unicode(datetime.date.today()) TaskRunFactory.create(task=self.project.tasks[1]) dates, dates_anon, dates_auth = stats.stats_dates(self.project.id) assert dates[today] == 1, dates assert dates_anon[today] == 4, dates_anon[today] assert dates_auth[today] == 5, dates_auth[today]
def test_stats_dates_no_completed_tasks_on_different_days(self): """Test STATS stats_dates with no completed tasks""" today = unicode(datetime.date.today()) dates, dates_anon, dates_auth = stats.stats_dates(self.project.id) assert len(dates.keys()) == 15, "There should be 15 days." for d in dates.keys(): assert dates[d] == 0, "There should be 0 completed tasks." assert dates_anon[today] == 4, dates_anon[today] assert dates_auth[today] == 4, dates_auth[today]
def test_01_stats_dates(self): """Test STATS dates method works""" today = unicode(datetime.date.today()) with self.app.test_request_context('/'): dates, dates_n_tasks, dates_anon, dates_auth = stats.stats_dates(1) err_msg = "There should be 10 answers today" assert dates[today] == 10, err_msg err_msg = "There should be 100 answers per day" assert dates_n_tasks[today] == 100, err_msg err_msg = "The SUM of answers from anon and auth users should be 10" assert (dates_anon[today] + dates_auth[today]) == 10, err_msg