Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions python/copr/test/client_v3/test_projects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from copr.test import config_location, mock
from copr.v3 import Client
from copr.v3.proxies.project import UserPermissions


class TestProjectProxy(object):
@mock.patch("copr.v3.proxies.Request.send")
def test_add(self, send):
client = Client.create_from_config_file(config_location)
client.project_proxy.add("user1", "foo", ["fedora-rawhide-x86_64"])
assert len(send.call_args_list) == 1
call = send.call_args_list[0]
args = call[1]
assert args["method"] == "POST"
assert args["params"]["ownername"] == "user1"
assert args["data"]["name"] == "foo"

@mock.patch("copr.v3.proxies.Request.send")
def test_set_permissions(self, send):
client = Client.create_from_config_file(config_location)
permissions: UserPermissions = {
"user1": {
"builder": "approved",
"admin": "nothing",
}
}
client.project_proxy.set_permissions("user1", "foo", permissions)
assert len(send.call_args_list) == 1
call = send.call_args_list[0]
args = call[1]
assert args["method"] == "PUT"
assert args["data"]["user1"] == {
"admin": "nothing",
"builder": "approved",
}
Loading