def test_user_progress_anonymous(self): """Test API userprogress as anonymous works""" user = UserFactory.create() project = ProjectFactory.create(owner=user) tasks = TaskFactory.create_batch(2, project=project) taskruns = [] for task in tasks: taskruns.extend(AnonymousTaskRunFactory.create_batch(2, task=task)) res = self.app.get('/api/project/1/userprogress', follow_redirects=True) data = json.loads(res.data) print data error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "The reported number of done tasks is wrong" assert len(taskruns) == data['done'], data # Add a new TaskRun and check again taskrun = AnonymousTaskRunFactory.create(task=tasks[0], info={'answer': u'hello'}) res = self.app.get('/api/project/1/userprogress', follow_redirects=True) data = json.loads(res.data) error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "Number of done tasks is wrong: %s" % len(taskruns) assert len(taskruns) + 1 == data['done'], error_msg
def test_user_progress_anonymous(self): """Test API userprogress as anonymous works""" user = UserFactory.create() project = ProjectFactory.create(owner=user) tasks = TaskFactory.create_batch(2, project=project) taskruns = [] for task in tasks: taskruns.extend(AnonymousTaskRunFactory.create_batch(2, task=task)) res = self.app.get('/api/project/1/userprogress', follow_redirects=True) data = json.loads(res.data) error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "The reported number of done tasks is wrong" assert len(taskruns) == data['done'], data # Add a new TaskRun and check again taskrun = AnonymousTaskRunFactory.create(task=tasks[0], info={'answer': u'hello'}) res = self.app.get('/api/project/1/userprogress', follow_redirects=True) data = json.loads(res.data) error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "Number of done tasks is wrong: %s" % len(taskruns) assert len(taskruns) + 1 == data['done'], error_msg
def test_user_progress_anonymous(self): """Test API userprogress as anonymous works""" user = UserFactory.create() app = AppFactory.create(owner=user) tasks = TaskFactory.create_batch(2, app=app) for task in tasks: taskruns = AnonymousTaskRunFactory.create_batch(2, task=task) taskruns = db.session.query(TaskRun)\ .filter(TaskRun.app_id == app.id)\ .filter(TaskRun.user_ip == '127.0.0.1')\ .all() res = self.app.get('/api/app/1/userprogress', follow_redirects=True) data = json.loads(res.data) error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "The reported number of done tasks is wrong" assert len(taskruns) == data['done'], data # Add a new TaskRun and check again taskrun = AnonymousTaskRunFactory.create(task=tasks[0], info={'answer': u'hello'}) res = self.app.get('/api/app/1/userprogress', follow_redirects=True) data = json.loads(res.data) error_msg = "The reported total number of tasks is wrong" assert len(tasks) == data['total'], error_msg error_msg = "Number of done tasks is wrong: %s" % len(taskruns) assert len(taskruns) + 1 == data['done'], error_msg