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