From b500d717f64aee8104f8033be4f98d6e2bc74128 Mon Sep 17 00:00:00 2001 From: Jakub Kadlčík Date: Jan 15 2019 13:34:29 +0000 Subject: [cli] fix side_effect function arguments When side_effect function is passed, it is called with the same arguments as the mock function. In this case it is a `BuildProxy.get(self, build_id)` However, "same arguments" means something different for current python and python2.6 which is on epel6. Now if method is mocked, then side_effect function is called with the method's self as the first argument. On epel it is not. --- diff --git a/cli/copr_cli/main.py b/cli/copr_cli/main.py index 2789a7d..91ebdf7 100644 --- a/cli/copr_cli/main.py +++ b/cli/copr_cli/main.py @@ -135,7 +135,7 @@ class Commands(object): if build_id in done: continue - build_details = self.client.build_proxy.get(build_id) + build_details = self.client.build_proxy.get(build_id=build_id) now = datetime.datetime.now() if prevstatus[build_id] != build_details.state: prevstatus[build_id] = build_details.state diff --git a/cli/tests/test_cli.py b/cli/tests/test_cli.py index 070256b..2508c67 100644 --- a/cli/tests/test_cli.py +++ b/cli/tests/test_cli.py @@ -500,18 +500,18 @@ class TestCreateBuild(object): def incr(*args, **kwargs): self.stage += 1 - def result_map(build_id, *args, **kwargs): + def result_map(*args, **kwargs): if self.stage == 0: return Munch(state="pending") elif self.stage == 1: smap = {0: "pending", 1: "starting", 2: "running"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) elif self.stage == 2: smap = {0: "starting", 1: "running", 2: "succeeded"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) elif self.stage == 3: smap = {0: "skipped", 1: "succeeded", 2: "succeeded"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) mock_time.sleep.side_effect = incr build_proxy_get.side_effect = result_map @@ -537,18 +537,18 @@ class TestCreateBuild(object): def incr(*args, **kwargs): self.stage += 1 - def result_map(build_id, *args, **kwargs): + def result_map(*args, **kwargs): if self.stage == 0: return Munch(state="pending") elif self.stage == 1: smap = {0: "pending", 1: "starting", 2: "running"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) elif self.stage == 2: smap = {0: "failed", 1: "running", 2: "succeeded"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) elif self.stage == 3: smap = {0: "failed", 1: "failed", 2: "succeeded"} - return Munch(state=smap[build_id]) + return Munch(state=smap[kwargs["build_id"]]) mock_time.sleep.side_effect = incr build_proxy_get.side_effect = result_map