class CloudFunctionTest(ClientTestCase): def setUp(self): super(CloudFunctionTest, self).setUp() self.function = CloudFunction("group_id", client=self.client) @responses.activate def test_call(self): self.mock_response(responses.POST, {'tasks': [{'id': 'foo'}]}) task = self.function("foo", bar="baz") self.assertEqual(self.function.group_id, task.guid) self.assertEqual("foo", task.tuid) self.assertEqual(("foo",), task.args) self.assertEqual({"bar": "baz"}, task.kwargs) @responses.activate def test_map(self): self.mock_response(responses.POST, {'tasks': [{'id': 'foo'}, {'id': 'bar'}]}) tasks = self.function.map(iter(["foo", "bar"])) self.assertEqual(["foo", "bar"], [task.tuid for task in tasks]) self.assertEqual([("foo",), ("bar",)], [task.args for task in tasks]) @responses.activate def test_map_multi(self): self.mock_response(responses.POST, {'tasks': [{'id': 'foo'}, {'id': 'bar'}]}) tasks = self.function.map(iter(["foo", "bar"]), iter(["baz"])) self.assertEqual(["foo", "bar"], [task.tuid for task in tasks]) self.assertEqual([("foo", "baz"), ("bar", None)], [task.args for task in tasks])
class CloudFunctionTest(ClientTestCase): def setUp(self): super(CloudFunctionTest, self).setUp() self.function = CloudFunction("group_id", client=self.client) @responses.activate def test_call(self): self.mock_response(responses.POST, {"tasks": [{"id": "foo"}]}) task = self.function("foo", bar="baz") assert self.function.group_id == task.guid assert "foo" == task.tuid assert ("foo",) == task.args assert {"bar": "baz"} == task.kwargs @responses.activate def test_map(self): self.mock_response(responses.POST, {"tasks": [{"id": "foo"}, {"id": "bar"}]}) tasks = self.function.map(iter(["foo", "bar"])) assert ["foo", "bar"] == [task.tuid for task in tasks] assert [("foo",), ("bar",)] == [task.args for task in tasks] @responses.activate def test_map_multi(self): self.mock_response(responses.POST, {"tasks": [{"id": "foo"}, {"id": "bar"}]}) tasks = self.function.map(iter(["foo", "bar"]), iter(["baz"])) assert ["foo", "bar"] == [task.tuid for task in tasks] assert [("foo", "baz"), ("bar", None)] == [task.args for task in tasks]
def setUp(self): super(CloudFunctionTest, self).setUp() self.function = CloudFunction("group_id", client=self.client)