def test_new_projects_week(self):
     """Test JOB update projects week works."""
     p = ProjectFactory.create()
     new_projects_week()
     sql = "select * from dashboard_week_project_new;"
     results = db.session.execute(sql)
     for row in results:
         assert row.id == p.id
         assert row.name == p.name
         assert row.owner_id == p.owner_id
         assert row.u_name == p.owner.name
         assert row.email_addr == p.owner.email_addr
 def test_new_projects_week(self):
     """Test JOB update projects week works."""
     p = ProjectFactory.create()
     new_projects_week()
     sql = "select * from dashboard_week_project_new;"
     results = db.session.execute(sql)
     for row in results:
         assert row.id == p.id
         assert row.name == p.name
         assert row.owner_id == p.owner_id
         assert row.u_name == p.owner.name
         assert row.email_addr == p.owner.email_addr
 def test_format_new_projects(self):
     """Test format new projects works."""
     p = ProjectFactory.create()
     new_projects_week()
     res = format_new_projects()
     day = datetime.utcnow().strftime('%Y-%m-%d')
     res = res[0]
     assert res['day'].strftime('%Y-%m-%d') == day, res['day']
     assert res['id'] == p.id
     assert res['short_name'] == p.short_name
     assert res['p_name'] == p.name
     assert res['email_addr'] == p.owner.email_addr
     assert res['owner_id'] == p.owner.id
     assert res['u_name'] == p.owner.name
 def test_format_new_projects(self):
     """Test format new projects works."""
     p = ProjectFactory.create()
     new_projects_week()
     res = format_new_projects()
     day = datetime.utcnow().strftime('%Y-%m-%d')
     res = res[0]
     assert res['day'].strftime('%Y-%m-%d') == day, res['day']
     assert res['id'] == p.id
     assert res['short_name'] == p.short_name
     assert res['p_name'] == p.name
     assert res['email_addr'] == p.owner.email_addr
     assert res['owner_id'] == p.owner.id
     assert res['u_name'] == p.owner.name
 def test_materialized_view_created(self, db_mock):
     """Test JOB dashboard materialized view is created."""
     result = MagicMock()
     result.exists = False
     results = [result]
     db_mock.slave_session.execute.return_value = results
     res = new_projects_week()
     assert db_mock.session.commit.called
     assert res == 'Materialized view created'
 def test_materialized_view_created(self, db_mock):
     """Test JOB dashboard materialized view is created."""
     result = MagicMock()
     result.exists = False
     results = [result]
     db_mock.slave_session.execute.return_value = results
     res = new_projects_week()
     assert db_mock.session.commit.called
     assert res == 'Materialized view created'
Esempio n. 7
0
 def test_admin_dashboard_admin_user_data(self):
     """Test ADMIN dashboard admins can access it with data"""
     url = '/admin/dashboard/'
     self.register()
     self.new_project()
     self.new_task(1)
     import pybossa.dashboard.jobs as dashboard
     dashboard.active_anon_week()
     dashboard.active_users_week()
     dashboard.new_users_week()
     dashboard.new_tasks_week()
     dashboard.new_task_runs_week()
     dashboard.new_projects_week()
     dashboard.update_projects_week()
     dashboard.returning_users_week()
     res = self.app.get(url, follow_redirects=True)
     err_msg = "It should return 200"
     assert res.status_code == 200, err_msg
     assert "No data" not in res.data, res.data
     assert "New Users" in res.data, res.data
Esempio n. 8
0
 def test_admin_dashboard_admin_user_data(self):
     """Test ADMIN dashboard admins can access it with data"""
     url = '/admin/dashboard/'
     self.register()
     self.new_project()
     self.new_task(1)
     import pybossa.dashboard.jobs as dashboard
     dashboard.active_anon_week()
     dashboard.active_users_week()
     dashboard.new_users_week()
     dashboard.new_tasks_week()
     dashboard.new_task_runs_week()
     dashboard.new_projects_week()
     dashboard.update_projects_week()
     dashboard.returning_users_week()
     res = self.app.get(url, follow_redirects=True)
     err_msg = "It should return 200"
     assert res.status_code == 200, err_msg
     assert "No data" not in res.data, res.data
     assert "New Users" in res.data, res.data