def test_complete_deleted_task(client, employee): client.open() resp = client.post(url_for('tasks_complete', task_id=1), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 404
def test_cannot_complete_foreign_task(client, task, employee): task['employee_id'] = employee['id'] + 10 update_task(task) resp = client.post(url_for('tasks_complete', task_id=task['id']), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 403
def test_create_missing_name(client, employer): client.open() resp = client.post(url_for('tasks_create'), data=json.dumps({}), headers=[ ('Authorization', 'Token ' + tokens.get_token(request, employer['id'])) ]) assert resp.status_code == 400 assert resp.json['error_code'] == 'bad_request'
def test_tasks_list_limit(tasks, client, employee): client.open() resp = client.get(url_for('tasks_list_unassigned') + "?limit=5", headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 200 assert len(resp.json) == 5
def test_tasks_list(client, tasks, employee): client.open() resp = client.get(url_for('tasks_list_unassigned'), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 200 assert len(resp.json) == 10 assert resp.json[0]['id'] == tasks[9]['id']
def test_get_profile(client, employee): client.open() resp = client.get(url_for('users_me'), headers=[('Authorization', 'Token ' + tokens.get_token(request, employee['id']))]) assert resp.status_code == 200 assert resp.json['id'] == employee['id'] assert resp.json['email'] == employee['email'] assert resp.json['type'] == employee['type']
def test_cannot_assign_not_ok_task(client, task, employee): task['ok'] = 0 update_task(task) client.open() resp = client.post(url_for('tasks_assign', task_id=task['id']), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 403
def test_assign_task(client, task, employee): client.open() resp = client.post(url_for('tasks_assign', task_id=task['id']), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) task = get_task_by_id(task['id']) assert resp.status_code == 200 assert task['employee_id'] == employee['id']
def test_complete_add_money(client, task, employee): client.open() task['employee_id'] = employee['id'] update_task(task) client.post(url_for('tasks_complete', task_id=task['id']), headers=[('Authorization', 'Token ' + get_token(request, employee['id']))]) employee = get_user_by_id(employee['id']) assert employee['balance'] == 300 * (1 - settings.SYSTEM_COMMISSION)
def test_create_minimal_params(client, employer): client.open() resp = client.post(url_for('tasks_create'), data=json.dumps({ 'name': 'Task 1', 'price': 200.40 }), headers=[ ('Authorization', 'Token ' + tokens.get_token(request, employer['id'])) ]) assert resp.status_code == 201 assert resp.json['id'] > 0 assert resp.json['name'] == 'Task 1' assert resp.json['price'] == 200.40 assert resp.json['description'] == ''
def test_create_task(client, employer): client.open() resp = client.post(url_for('tasks_create'), data=json.dumps({ 'name': 'Task 1', 'description': 'My first task', 'price': 200, }), headers=[ ('Authorization', 'Token ' + tokens.get_token(request, employer['id'])) ]) assert resp.status_code == 201, resp.json['error_message'] assert resp.json['id'] > 0 assert resp.json['name'] == 'Task 1' assert resp.json['price'] == 200 assert resp.json['description'] == 'My first task' assert resp.json['author_id'] == employer['id'] assert resp.json['status'] == 'open'
def test_not_ok_task_is_hidden(client, employer, employee): create_task( make_task( **{ 'id': 1, 'name': 'Task', 'price': 300, 'author_id': employer['id'], 'description': '', 'status': 'open', 'ok': 0 })) client.open() resp = client.get(url_for('tasks_list_unassigned'), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 200 assert len(resp.json) == 0
def test_cannot_complete_unassigned_task(client, task, employee): resp = client.post(url_for('tasks_complete', task_id=task['id']), headers=[('Authorization', 'Token ' + get_token(request, employee['id'])) ]) assert resp.status_code == 403