|
Matt Prahl |
1a51d9 |
# -*- coding: utf-8 -*-
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
1a51d9 |
(c) 2017 - Copyright Red Hat Inc
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
Authors:
|
|
Matt Prahl |
1a51d9 |
Matt Prahl <mprahl@redhat.com></mprahl@redhat.com>
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
__requires__ = ['SQLAlchemy >= 0.8']
|
|
Matt Prahl |
1a51d9 |
import unittest
|
|
Matt Prahl |
1a51d9 |
import sys
|
|
Matt Prahl |
1a51d9 |
import os
|
|
Matt Prahl |
1a51d9 |
import json
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
sys.path.insert(0, os.path.join(os.path.dirname(
|
|
Matt Prahl |
1a51d9 |
os.path.abspath(__file__)), '..'))
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
import pagure.api
|
|
Matt Prahl |
1a51d9 |
import pagure.lib
|
|
Matt Prahl |
1a51d9 |
import tests
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
|
|
Clement Verna |
109c4b |
class PagureFlaskApiGroupTests(tests.SimplePagureTest):
|
|
Matt Prahl |
1a51d9 |
""" Tests for the flask API of pagure for issue """
|
|
Matt Prahl |
1a51d9 |
|
|
Pierre-Yves Chibon |
6fa1ec |
maxDiff = None
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Matt Prahl |
1a51d9 |
def setUp(self):
|
|
Matt Prahl |
1a51d9 |
""" Set up the environnment, ran before every tests. """
|
|
Matt Prahl |
1a51d9 |
super(PagureFlaskApiGroupTests, self).setUp()
|
|
Matt Prahl |
1a51d9 |
|
|
Pierre-Yves Chibon |
b130e5 |
pagure.config.config['REQUESTS_FOLDER'] = None
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
msg = pagure.lib.add_group(
|
|
Matt Prahl |
1a51d9 |
self.session,
|
|
Matt Prahl |
1a51d9 |
group_name='some_group',
|
|
Matt Prahl |
1a51d9 |
display_name='Some Group',
|
|
Matt Prahl |
1a51d9 |
description=None,
|
|
Matt Prahl |
1a51d9 |
group_type='bar',
|
|
Matt Prahl |
1a51d9 |
user='pingou',
|
|
Matt Prahl |
1a51d9 |
is_admin=False,
|
|
Matt Prahl |
1a51d9 |
blacklist=[],
|
|
Matt Prahl |
1a51d9 |
)
|
|
Matt Prahl |
1a51d9 |
self.session.commit()
|
|
Matt Prahl |
1a51d9 |
|
|
Pierre-Yves Chibon |
6fa1ec |
tests.create_projects(self.session)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
project = pagure.lib._get_project(self.session, 'test2')
|
|
Pierre-Yves Chibon |
6fa1ec |
msg = pagure.lib.add_group_to_project(
|
|
Pierre-Yves Chibon |
6fa1ec |
session=self.session,
|
|
Pierre-Yves Chibon |
6fa1ec |
project=project,
|
|
Pierre-Yves Chibon |
6fa1ec |
new_group='some_group',
|
|
Pierre-Yves Chibon |
6fa1ec |
user='pingou',
|
|
Pierre-Yves Chibon |
6fa1ec |
)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.session.commit()
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(msg, 'Group added')
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
802ab8 |
def test_api_groups(self):
|
|
Matt Prahl |
802ab8 |
""" Test the api_groups function. """
|
|
Matt Prahl |
802ab8 |
|
|
Matt Prahl |
802ab8 |
# Add a couple of groups so that we can list them
|
|
Matt Prahl |
802ab8 |
item = pagure.lib.model.PagureGroup(
|
|
Matt Prahl |
802ab8 |
group_name='group1',
|
|
Matt Prahl |
802ab8 |
group_type='user',
|
|
Matt Prahl |
802ab8 |
display_name='User group',
|
|
Matt Prahl |
802ab8 |
user_id=1, # pingou
|
|
Matt Prahl |
802ab8 |
)
|
|
Matt Prahl |
802ab8 |
self.session.add(item)
|
|
Matt Prahl |
802ab8 |
|
|
Matt Prahl |
802ab8 |
item = pagure.lib.model.PagureGroup(
|
|
Matt Prahl |
802ab8 |
group_name='rel-eng',
|
|
Matt Prahl |
802ab8 |
group_type='user',
|
|
Matt Prahl |
802ab8 |
display_name='Release engineering group',
|
|
Matt Prahl |
802ab8 |
user_id=1, # pingou
|
|
Matt Prahl |
802ab8 |
)
|
|
Matt Prahl |
802ab8 |
self.session.add(item)
|
|
Matt Prahl |
802ab8 |
self.session.commit()
|
|
Matt Prahl |
802ab8 |
|
|
Matt Prahl |
802ab8 |
output = self.app.get('/api/0/groups')
|
|
Matt Prahl |
802ab8 |
self.assertEqual(output.status_code, 200)
|
|
Matt Prahl |
802ab8 |
data = json.loads(output.data)
|
|
Matt Prahl |
802ab8 |
self.assertEqual(data['groups'], ['some_group', 'group1', 'rel-eng'])
|
|
Matt Prahl |
802ab8 |
self.assertEqual(sorted(data.keys()), ['groups', 'total_groups'])
|
|
Matt Prahl |
802ab8 |
self.assertEqual(data['total_groups'], 3)
|
|
Matt Prahl |
802ab8 |
|
|
Matt Prahl |
802ab8 |
output = self.app.get('/api/0/groups?pattern=re')
|
|
Matt Prahl |
802ab8 |
self.assertEqual(output.status_code, 200)
|
|
Matt Prahl |
802ab8 |
data = json.loads(output.data)
|
|
Matt Prahl |
802ab8 |
self.assertEqual(data['groups'], ['rel-eng'])
|
|
Matt Prahl |
802ab8 |
self.assertEqual(sorted(data.keys()), ['groups', 'total_groups'])
|
|
Matt Prahl |
802ab8 |
self.assertEqual(data['total_groups'], 1)
|
|
Matt Prahl |
802ab8 |
|
|
Pierre-Yves Chibon |
2231a1 |
def test_api_groups_extended(self):
|
|
Pierre-Yves Chibon |
2231a1 |
""" Test the api_groups function. """
|
|
Pierre-Yves Chibon |
2231a1 |
|
|
Pierre-Yves Chibon |
2231a1 |
# Add a couple of groups so that we can list them
|
|
Pierre-Yves Chibon |
2231a1 |
item = pagure.lib.model.PagureGroup(
|
|
Pierre-Yves Chibon |
2231a1 |
group_name='group1',
|
|
Pierre-Yves Chibon |
2231a1 |
group_type='user',
|
|
Pierre-Yves Chibon |
2231a1 |
display_name='User group',
|
|
Pierre-Yves Chibon |
2231a1 |
user_id=1, # pingou
|
|
Pierre-Yves Chibon |
2231a1 |
)
|
|
Pierre-Yves Chibon |
2231a1 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
2231a1 |
|
|
Pierre-Yves Chibon |
2231a1 |
item = pagure.lib.model.PagureGroup(
|
|
Pierre-Yves Chibon |
2231a1 |
group_name='rel-eng',
|
|
Pierre-Yves Chibon |
2231a1 |
group_type='user',
|
|
Pierre-Yves Chibon |
2231a1 |
display_name='Release engineering group',
|
|
Pierre-Yves Chibon |
2231a1 |
user_id=1, # pingou
|
|
Pierre-Yves Chibon |
2231a1 |
)
|
|
Pierre-Yves Chibon |
2231a1 |
self.session.add(item)
|
|
Pierre-Yves Chibon |
2231a1 |
self.session.commit()
|
|
Pierre-Yves Chibon |
2231a1 |
|
|
Pierre-Yves Chibon |
2231a1 |
output = self.app.get('/api/0/groups?extended=1')
|
|
Pierre-Yves Chibon |
2231a1 |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
2231a1 |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
2231a1 |
self.assertEqual(
|
|
Pierre-Yves Chibon |
2231a1 |
data,
|
|
Pierre-Yves Chibon |
2231a1 |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"groups": [
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "group1"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "rel-eng"
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"total_groups": 3
|
|
Pierre-Yves Chibon |
2231a1 |
}
|
|
Pierre-Yves Chibon |
2231a1 |
)
|
|
Pierre-Yves Chibon |
2231a1 |
|
|
Matt Prahl |
9264b1 |
def test_api_view_group_authenticated(self):
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
9264b1 |
Test the api_view_group method of the flask api with an
|
|
Matt Prahl |
9264b1 |
authenticated user. The tested group has one member.
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
9264b1 |
tests.create_tokens(self.session)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Matt Prahl |
9264b1 |
headers = {'Authorization': 'token aaabbbcccddd'}
|
|
Matt Prahl |
9264b1 |
output = self.app.get('/api/0/group/some_group', headers=headers)
|
|
Matt Prahl |
1a51d9 |
self.assertEqual(output.status_code, 200)
|
|
Matt Prahl |
1a51d9 |
exp = {
|
|
Matt Prahl |
1a51d9 |
"display_name": "Some Group",
|
|
Matt Prahl |
1a51d9 |
"description": None,
|
|
Matt Prahl |
1a51d9 |
"creator": {
|
|
Matt Prahl |
1a51d9 |
"fullname": "PY C",
|
|
Matt Prahl |
1a51d9 |
"default_email": "bar@pingou.com",
|
|
Matt Prahl |
1a51d9 |
"emails": [
|
|
Matt Prahl |
1a51d9 |
"bar@pingou.com",
|
|
Matt Prahl |
1a51d9 |
"foo@pingou.com"
|
|
Matt Prahl |
1a51d9 |
],
|
|
Matt Prahl |
1a51d9 |
"name": "pingou"
|
|
Matt Prahl |
1a51d9 |
},
|
|
Matt Prahl |
1a51d9 |
"members": ["pingou"],
|
|
Matt Prahl |
1a51d9 |
"date_created": "1492020239",
|
|
Matt Prahl |
1a51d9 |
"group_type": "user",
|
|
Matt Prahl |
1a51d9 |
"name": "some_group"
|
|
Matt Prahl |
1a51d9 |
}
|
|
Matt Prahl |
1a51d9 |
data = json.loads(output.data)
|
|
Matt Prahl |
1a51d9 |
data['date_created'] = '1492020239'
|
|
Matt Prahl |
1a51d9 |
self.assertDictEqual(data, exp)
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
9264b1 |
def test_api_view_group_unauthenticated(self):
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
9264b1 |
Test the api_view_group method of the flask api with an
|
|
Matt Prahl |
9264b1 |
unauthenticated user. The tested group has one member.
|
|
Matt Prahl |
9264b1 |
"""
|
|
Matt Prahl |
9264b1 |
output = self.app.get('/api/0/group/some_group')
|
|
Matt Prahl |
9264b1 |
self.assertEqual(output.status_code, 200)
|
|
Matt Prahl |
9264b1 |
exp = {
|
|
Matt Prahl |
9264b1 |
"display_name": "Some Group",
|
|
Matt Prahl |
9264b1 |
"description": None,
|
|
Matt Prahl |
9264b1 |
"creator": {
|
|
Matt Prahl |
9264b1 |
"fullname": "PY C",
|
|
Matt Prahl |
9264b1 |
"name": "pingou"
|
|
Matt Prahl |
9264b1 |
},
|
|
Matt Prahl |
9264b1 |
"members": ["pingou"],
|
|
Matt Prahl |
9264b1 |
"date_created": "1492020239",
|
|
Matt Prahl |
9264b1 |
"group_type": "user",
|
|
Matt Prahl |
9264b1 |
"name": "some_group"
|
|
Matt Prahl |
9264b1 |
}
|
|
Matt Prahl |
9264b1 |
data = json.loads(output.data)
|
|
Matt Prahl |
9264b1 |
data['date_created'] = '1492020239'
|
|
Matt Prahl |
9264b1 |
self.assertDictEqual(data, exp)
|
|
Matt Prahl |
9264b1 |
|
|
Matt Prahl |
9264b1 |
def test_api_view_group_two_members_authenticated(self):
|
|
Matt Prahl |
9264b1 |
"""
|
|
Matt Prahl |
9264b1 |
Test the api_view_group method of the flask api with an
|
|
Matt Prahl |
9264b1 |
authenticated user. The tested group has two members.
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
1a51d9 |
user = pagure.lib.model.User(
|
|
Matt Prahl |
1a51d9 |
user='mprahl',
|
|
Matt Prahl |
1a51d9 |
fullname='Matt Prahl',
|
|
Matt Prahl |
1a51d9 |
password='foo',
|
|
Matt Prahl |
1a51d9 |
default_email='mprahl@redhat.com',
|
|
Matt Prahl |
1a51d9 |
)
|
|
Matt Prahl |
1a51d9 |
self.session.add(user)
|
|
Matt Prahl |
1a51d9 |
self.session.commit()
|
|
Matt Prahl |
1a51d9 |
group = pagure.lib.search_groups(self.session, group_name='some_group')
|
|
Matt Prahl |
1a51d9 |
result = pagure.lib.add_user_to_group(
|
|
Matt Prahl |
1a51d9 |
self.session, user.username, group, user.username, True)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(
|
|
Pierre-Yves Chibon |
6fa1ec |
result, 'User `mprahl` added to the group `some_group`.')
|
|
Matt Prahl |
1a51d9 |
self.session.commit()
|
|
Matt Prahl |
9264b1 |
|
|
Matt Prahl |
9264b1 |
tests.create_tokens(self.session)
|
|
Pierre-Yves Chibon |
14e826 |
|
|
Matt Prahl |
9264b1 |
headers = {'Authorization': 'token aaabbbcccddd'}
|
|
Matt Prahl |
9264b1 |
output = self.app.get('/api/0/group/some_group', headers=headers)
|
|
Matt Prahl |
1a51d9 |
self.assertEqual(output.status_code, 200)
|
|
Matt Prahl |
1a51d9 |
exp = {
|
|
Matt Prahl |
1a51d9 |
"display_name": "Some Group",
|
|
Matt Prahl |
1a51d9 |
"description": None,
|
|
Matt Prahl |
1a51d9 |
"creator": {
|
|
Matt Prahl |
1a51d9 |
"fullname": "PY C",
|
|
Matt Prahl |
1a51d9 |
"default_email": "bar@pingou.com",
|
|
Matt Prahl |
1a51d9 |
"emails": [
|
|
Matt Prahl |
1a51d9 |
"bar@pingou.com",
|
|
Matt Prahl |
1a51d9 |
"foo@pingou.com"
|
|
Matt Prahl |
1a51d9 |
],
|
|
Matt Prahl |
1a51d9 |
"name": "pingou"
|
|
Matt Prahl |
1a51d9 |
},
|
|
Matt Prahl |
1a51d9 |
"members": ["pingou", "mprahl"],
|
|
Matt Prahl |
1a51d9 |
"date_created": "1492020239",
|
|
Matt Prahl |
1a51d9 |
"group_type": "user",
|
|
Matt Prahl |
1a51d9 |
"name": "some_group"
|
|
Matt Prahl |
1a51d9 |
}
|
|
Matt Prahl |
1a51d9 |
self.maxDiff = None
|
|
Matt Prahl |
1a51d9 |
data = json.loads(output.data)
|
|
Matt Prahl |
1a51d9 |
data['date_created'] = '1492020239'
|
|
Matt Prahl |
1a51d9 |
self.assertDictEqual(data, exp)
|
|
Matt Prahl |
1a51d9 |
|
|
Matt Prahl |
1a51d9 |
def test_api_view_group_no_group_error(self):
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
1a51d9 |
Test the api_view_group method of the flask api
|
|
Matt Prahl |
1a51d9 |
The tested group has one member.
|
|
Matt Prahl |
1a51d9 |
"""
|
|
Matt Prahl |
1a51d9 |
output = self.app.get("/api/0/group/some_group3")
|
|
Matt Prahl |
1a51d9 |
self.assertEqual(output.status_code, 404)
|
|
Matt Prahl |
1a51d9 |
data = json.loads(output.data)
|
|
Matt Prahl |
1a51d9 |
self.assertEqual(data['error'], 'Group not found')
|
|
Matt Prahl |
1a51d9 |
self.assertEqual(data['error_code'], 'ENOGROUP')
|
|
Matt Prahl |
1a51d9 |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the admin ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
tests.create_tokens(self.session)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
headers = {'Authorization': 'token aaabbbcccddd'}
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1', headers=headers)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Some Group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"default_email": "bar@pingou.com",
|
|
Pierre-Yves Chibon |
6fa1ec |
"emails": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"bar@pingou.com",
|
|
Pierre-Yves Chibon |
6fa1ec |
"foo@pingou.com"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": ["pingou"],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": [
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_groups": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"some_group"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_users": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"owner": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"close_status": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"Invalid",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Insufficient data",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Fixed",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Duplicate"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"custom_keys": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_modified": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": "test project #2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"id": 2,
|
|
Pierre-Yves Chibon |
6fa1ec |
"milestones": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"namespace": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"parent": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"priorities": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"settings": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"Enforce_signed-off_commits_in_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Minimum_score_to_merge_pull-request": -1,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Only_assignee_can_merge_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Web-hooks": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"always_merge": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"fedmsg_notifications": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issue_tracker": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issues_default_to_private": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"project_documentation": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"pull_request_access_only": False,
|
|
Pierre-Yves Chibon |
960e1e |
"pull_requests": True,
|
|
Pierre-Yves Chibon |
960e1e |
"roadmap_on_issues_page": False
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"tags": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"url_path": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"user": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
]
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects = []
|
|
Pierre-Yves Chibon |
6fa1ec |
for p in data['projects']:
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_modified'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects.append(p)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['projects'] = projects
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output2 = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1&acl=admin', headers=headers)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.data.split('\n'), output2.data.split('\n'))
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl_commit(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the commit ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1&acl=commit')
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Some Group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": ["pingou"],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": [
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_groups": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"some_group"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_users": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"owner": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"close_status": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"Invalid",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Insufficient data",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Fixed",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Duplicate"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"custom_keys": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_modified": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": "test project #2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"id": 2,
|
|
Pierre-Yves Chibon |
6fa1ec |
"milestones": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"namespace": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"parent": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"priorities": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"settings": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"Enforce_signed-off_commits_in_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Minimum_score_to_merge_pull-request": -1,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Only_assignee_can_merge_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Web-hooks": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"always_merge": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"fedmsg_notifications": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issue_tracker": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issues_default_to_private": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"project_documentation": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"pull_request_access_only": False,
|
|
Pierre-Yves Chibon |
960e1e |
"pull_requests": True,
|
|
Pierre-Yves Chibon |
960e1e |
"roadmap_on_issues_page": False
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"tags": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"url_path": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"user": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
]
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects = []
|
|
Pierre-Yves Chibon |
6fa1ec |
for p in data['projects']:
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_modified'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects.append(p)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['projects'] = projects
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl_ticket(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the ticket ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1&acl=ticket')
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Some Group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": ["pingou"],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": [
|
|
Pierre-Yves Chibon |
6fa1ec |
{
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_groups": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"some_group"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"access_users": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"admin": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"commit": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"owner": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"ticket": []
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"close_status": [
|
|
Pierre-Yves Chibon |
6fa1ec |
"Invalid",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Insufficient data",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Fixed",
|
|
Pierre-Yves Chibon |
6fa1ec |
"Duplicate"
|
|
Pierre-Yves Chibon |
6fa1ec |
],
|
|
Pierre-Yves Chibon |
6fa1ec |
"custom_keys": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_modified": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": "test project #2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"id": 2,
|
|
Pierre-Yves Chibon |
6fa1ec |
"milestones": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"namespace": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"parent": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"priorities": {},
|
|
Pierre-Yves Chibon |
6fa1ec |
"settings": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"Enforce_signed-off_commits_in_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Minimum_score_to_merge_pull-request": -1,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Only_assignee_can_merge_pull-request": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"Web-hooks": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"always_merge": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"fedmsg_notifications": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issue_tracker": True,
|
|
Pierre-Yves Chibon |
6fa1ec |
"issues_default_to_private": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"project_documentation": False,
|
|
Pierre-Yves Chibon |
6fa1ec |
"pull_request_access_only": False,
|
|
Pierre-Yves Chibon |
960e1e |
"pull_requests": True,
|
|
Pierre-Yves Chibon |
960e1e |
"roadmap_on_issues_page": False
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"tags": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"url_path": "test2",
|
|
Pierre-Yves Chibon |
6fa1ec |
"user": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
]
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects = []
|
|
Pierre-Yves Chibon |
6fa1ec |
for p in data['projects']:
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
p['date_modified'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
projects.append(p)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['projects'] = projects
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl_admin_no_project(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the admin ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
# Make the group having only commit access
|
|
Pierre-Yves Chibon |
6fa1ec |
project = pagure.lib._get_project(self.session, 'test2')
|
|
Pierre-Yves Chibon |
6fa1ec |
msg = pagure.lib.add_group_to_project(
|
|
Pierre-Yves Chibon |
6fa1ec |
session=self.session,
|
|
Pierre-Yves Chibon |
6fa1ec |
project=project,
|
|
Pierre-Yves Chibon |
6fa1ec |
new_group='some_group',
|
|
Pierre-Yves Chibon |
6fa1ec |
user='pingou',
|
|
Pierre-Yves Chibon |
6fa1ec |
access='commit',
|
|
Pierre-Yves Chibon |
6fa1ec |
)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.session.commit()
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(msg, 'Group access updated')
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1&acl=admin')
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Some Group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": ["pingou"],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": []
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl_commit_no_project(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the commit ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
# Make the group having only ticket access
|
|
Pierre-Yves Chibon |
6fa1ec |
project = pagure.lib._get_project(self.session, 'test2')
|
|
Pierre-Yves Chibon |
6fa1ec |
msg = pagure.lib.add_group_to_project(
|
|
Pierre-Yves Chibon |
6fa1ec |
session=self.session,
|
|
Pierre-Yves Chibon |
6fa1ec |
project=project,
|
|
Pierre-Yves Chibon |
6fa1ec |
new_group='some_group',
|
|
Pierre-Yves Chibon |
6fa1ec |
user='pingou',
|
|
Pierre-Yves Chibon |
6fa1ec |
access='ticket',
|
|
Pierre-Yves Chibon |
6fa1ec |
)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.session.commit()
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(msg, 'Group access updated')
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/some_group?projects=1&acl=commit')
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Some Group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": ["pingou"],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "some_group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": []
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
def test_api_view_group_w_projects_and_acl_ticket_no_project(self):
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
Test the api_view_group method with project info and restricted
|
|
Pierre-Yves Chibon |
6fa1ec |
to the ticket ACL
|
|
Pierre-Yves Chibon |
6fa1ec |
"""
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
# Create a group not linked to any project
|
|
Pierre-Yves Chibon |
6fa1ec |
item = pagure.lib.model.PagureGroup(
|
|
Pierre-Yves Chibon |
6fa1ec |
group_name='rel-eng',
|
|
Pierre-Yves Chibon |
6fa1ec |
group_type='user',
|
|
Pierre-Yves Chibon |
6fa1ec |
display_name='Release engineering group',
|
|
Pierre-Yves Chibon |
6fa1ec |
user_id=1, # pingou
|
|
Pierre-Yves Chibon |
6fa1ec |
)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.session.add(item)
|
|
Pierre-Yves Chibon |
6fa1ec |
self.session.commit()
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
output = self.app.get(
|
|
Pierre-Yves Chibon |
6fa1ec |
'/api/0/group/rel-eng?projects=1&acl=ticket')
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertEqual(output.status_code, 200)
|
|
Pierre-Yves Chibon |
6fa1ec |
exp = {
|
|
Pierre-Yves Chibon |
6fa1ec |
"display_name": "Release engineering group",
|
|
Pierre-Yves Chibon |
6fa1ec |
"description": None,
|
|
Pierre-Yves Chibon |
6fa1ec |
"creator": {
|
|
Pierre-Yves Chibon |
6fa1ec |
"fullname": "PY C",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "pingou"
|
|
Pierre-Yves Chibon |
6fa1ec |
},
|
|
Pierre-Yves Chibon |
6fa1ec |
"members": [],
|
|
Pierre-Yves Chibon |
6fa1ec |
"date_created": "1492020239",
|
|
Pierre-Yves Chibon |
6fa1ec |
"group_type": "user",
|
|
Pierre-Yves Chibon |
6fa1ec |
"name": "rel-eng",
|
|
Pierre-Yves Chibon |
6fa1ec |
"projects": []
|
|
Pierre-Yves Chibon |
6fa1ec |
}
|
|
Pierre-Yves Chibon |
6fa1ec |
data = json.loads(output.data)
|
|
Pierre-Yves Chibon |
6fa1ec |
data['date_created'] = '1492020239'
|
|
Pierre-Yves Chibon |
6fa1ec |
self.assertDictEqual(data, exp)
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Pierre-Yves Chibon |
6fa1ec |
|
|
Matt Prahl |
1a51d9 |
if __name__ == "__main__":
|
|
Pierre-Yves Chibon |
393f31 |
unittest.main(verbosity=2)
|