def test_active_week(self):
     """Test JOB dashboard returns active users week runs."""
     TaskRunFactory.create()
     AnonymousTaskRunFactory.create()
     active_users_week()
     sql = "select * from dashboard_week_users;"
     results = db.session.execute(sql)
     for row in results:
         assert row.n_users == 1, row.n_users
    def test_anon_week(self):
        """Test JOB dashboard returns anon active week runs."""
        TaskRunFactory.create()
        AnonymousTaskRunFactory.create()
        active_anon_week()
        sql = "select * from dashboard_week_anon;"
        results = db.session.execute(sql).fetchall()

        assert results[0].n_users == 1, results[0].n_users
 def test_anon_week(self):
     """Test JOB dashboard returns anon active week runs."""
     TaskRunFactory.create()
     AnonymousTaskRunFactory.create()
     dashboard_active_anon_week()
     sql = "select * from dashboard_week_anon;"
     results = db.session.execute(sql)
     for row in results:
         assert row.n_users == 1, row.n_users
    def test_anon_week(self):
        """Test JOB dashboard returns anon active week runs."""
        TaskRunFactory.create()
        AnonymousTaskRunFactory.create()
        active_anon_week()
        sql = "select * from dashboard_week_anon;"
        results = db.session.execute(sql).fetchall()

        assert results[0].n_users == 1, results[0].n_users
 def test_format_anon_week(self):
     """Test format anon week works."""
     AnonymousTaskRunFactory.create()
     active_anon_week()
     res = format_anon_week()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day
     assert len(res['series']) == 1
     assert res['series'][0][0] == 1, res['series'][0][0]
 def test_format_anon_week(self):
     """Test format anon week works."""
     AnonymousTaskRunFactory.create()
     active_anon_week()
     res = format_anon_week()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day
     assert len(res['series']) == 1
     assert res['series'][0][0] == 1, res['series'][0][0]
 def test_format_new_task_runs(self):
     """Test format new task_runs works."""
     TaskRunFactory.create()
     AnonymousTaskRunFactory.create()
     new_task_runs_week()
     res = format_new_task_runs()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day, res
     assert len(res['series']) == 1
     assert res['series'][0][0] == 2, res['series'][0][0]
 def test_format_new_task_runs(self):
     """Test format new task_runs works."""
     TaskRunFactory.create()
     AnonymousTaskRunFactory.create()
     new_task_runs_week()
     res = format_new_task_runs()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day, res
     assert len(res['series']) == 1
     assert res['series'][0][0] == 2, res['series'][0][0]
 def test_format_users_week_empty(self, db_mock):
     """Test format users week empty works."""
     db_mock.slave_session.execute.return_value = []
     AnonymousTaskRunFactory.create()
     active_users_week()
     res = format_users_week()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day
     assert len(res['series']) == 1
     assert res['series'][0][0] == 0, res['series'][0][0]
 def test_format_users_week_empty(self, db_mock):
     """Test format users week empty works."""
     db_mock.slave_session.execute.return_value = []
     AnonymousTaskRunFactory.create()
     active_users_week()
     res = format_users_week()
     assert len(res['labels']) == 1
     day = datetime.utcnow().strftime('%Y-%m-%d')
     assert res['labels'][0] == day
     assert len(res['series']) == 1
     assert res['series'][0][0] == 0, res['series'][0][0]