1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#
# Copyright Red Hat, Inc. 2012
#
# This work is licensed under the GNU GPLv2 or later.
# See the COPYING file in the top-level directory.
#
"""
Test miscellaneous API bits
"""
import tests
import tests.mockbackend
def test_api_groups():
# Basic API testing of the users APIs
group_ret = {"groups": [{
"membership": [
{"real_name": "Bugzilla User",
"can_login": 1,
"name": "user@bugzilla.org",
"login_denied_text": "",
"id": 85,
"email_enabled": 1,
"email": "user@bugzilla.org"},
{"real_name": "Bugzilla User2",
"can_login": 0,
"name": "user2@bugzilla.org",
"login_denied_text": "",
"id": 77,
"email_enabled": 0,
"email": "user2@bugzilla.org"},
],
"is_active": 1,
"description": "Test Group",
"user_regexp": "",
"is_bug_group": 1,
"name": "TestGroup",
"id": 9
}]}
fakebz = tests.mockbackend.make_bz(
group_get_args="data/mockargs/test_api_groups_get1.txt",
group_get_return=group_ret)
# getgroups testing
groupobj = fakebz.getgroups("TestGroups")[0]
assert groupobj.groupid == 9
assert groupobj.member_emails == [
"user2@bugzilla.org", "user@bugzilla.org"]
assert groupobj.name == "TestGroup"
# getgroup testing
fakebz = tests.mockbackend.make_bz(
group_get_args="data/mockargs/test_api_groups_get2.txt",
group_get_return=group_ret)
groupobj = fakebz.getgroup("TestGroup", membership=True)
groupobj.membership = []
assert groupobj.members() == group_ret["groups"][0]["membership"]
|