Read about our upcoming Code of Conduct on this issue

Commit 75b1a4c3 authored by Georges Racinet's avatar Georges Racinet 🦑
Browse files

Merge Requests: using the new Project.api_request()

A bit cleaner this way.

One day, we may reduce the duplication by introducing
a proper MergeRequest object.
parent 87ec879f4ac1
# -*- coding: utf-8 -*-
import json
import pytest
import requests
from import WebDriverWait
from .utils import (
......@@ -182,20 +181,18 @@ def assert_merge_detected(project, mr_id, named_branch=None, timeout=10):
def assert_user_cannot_merge(user_name, project, mr_id):
user = project.heptapod.get_user(user_name)
headers = {'Private-Token': user.token}
mr_url = '%s/merge_requests/%d' % (project.api_url, mr_id)
mr_uri = 'merge_requests/%d' % mr_id
# let's decrease chances of false negatives by testing that user has
# access to the MR (projects tend to be private by default).
# We could do better by, e.g., adding a comment but that requires only
# the Reporter role.
resp = requests.get(mr_url, headers=headers)
resp = project.api_request('GET', user, subpath=mr_uri)
assert resp.status_code == 200
resp = requests.put(mr_url + '/merge',
resp = project.api_request('PUT', user, subpath=mr_uri + '/merge',
assert resp.status_code >= 400
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment