diff --git a/pynautobot/core/endpoint.py b/pynautobot/core/endpoint.py index 12edef1..e3a43db 100644 --- a/pynautobot/core/endpoint.py +++ b/pynautobot/core/endpoint.py @@ -364,9 +364,21 @@ def update(self, *args, **kwargs): objects = args[0] if args else [] if not isinstance(objects, list): raise ValueError("objects must be a list[dict()|Record] not " + str(type(objects))) + if "data" in kwargs and "id" in kwargs: - kwargs["data"]["id"] = kwargs["id"] - objects.append(kwargs["data"]) + uuid = kwargs["id"] + data = kwargs["data"] + + req = Request( + key=uuid, + base=self.url, + token=self.api.token, + http_session=self.api.http_session, + api_version=self.api.api_version, + ) + if req.patch(data): + return True + return False data = [] for o in objects: diff --git a/tests/unit/test_endpoint.py b/tests/unit/test_endpoint.py index e3ac8d3..9d02656 100644 --- a/tests/unit/test_endpoint.py +++ b/tests/unit/test_endpoint.py @@ -57,9 +57,9 @@ def test_update_with_id_and_data(self): api = Mock(base_url="http://localhost:8000/api") app = Mock(name="test") test_obj = Endpoint(api, app, "test") - mock.return_value = [{"id": "db8770c4-61e5-4999-8372-e7fa576a4f65", "name": "test"}] + mock.return_value = [{"name": "test"}] test = test_obj.update(id="db8770c4-61e5-4999-8372-e7fa576a4f65", data={"name": "test"}) - mock.assert_called_with(verb="patch", data=[{"id": "db8770c4-61e5-4999-8372-e7fa576a4f65", "name": "test"}]) + mock.assert_called_with(verb="patch", data={"name": "test"}) self.assertTrue(test) def test_update_with_dict(self):