Esempio n. 1
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 = published_projects_week()
     assert db_mock.session.commit.called
     assert res == 'Materialized view created'
Esempio n. 2
0
    def test_format_published_projects_week(self):
        """Test format published_projects_week works."""
        ProjectFactory.create(published=False)
        p = ProjectFactory.create(published=True)
        auditlogger = AuditLogger(auditlog_repo, caller='web')
        auditlogger.log_event(p, p.owner, 'update', 'published', False, True)
        published_projects_week()
        day = datetime.utcnow().strftime('%Y-%m-%d')

        res = format_published_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
Esempio 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
Esempio 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