Ejemplo n.º 1
0
    def test_format_new_projects(self):
        """Test format draft_projects_week works."""
        ProjectFactory.create(published=True)
        p = ProjectFactory.create(published=False)
        draft_projects_week()
        day = datetime.utcnow().strftime('%Y-%m-%d')

        res = format_draft_projects()

        assert len(res) == 1, res
        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
Ejemplo n.º 2
0
 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 = draft_projects_week()
     assert db_mock.session.commit.called
     assert res == 'Materialized view created'
Ejemplo n.º 3
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.draft_projects_week()
     dashboard.published_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
Ejemplo n.º 4
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.draft_projects_week()
     dashboard.published_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