Skip to content

Commit

Permalink
Merge pull request #287 from digitalocean/fix-nested-update
Browse files Browse the repository at this point in the history
Always send self.id with save() and delete()
  • Loading branch information
Zach Moody authored Sep 2, 2020
2 parents 83ee65c + aa198fd commit c45411a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/py3pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
python-version: ${{ matrix.python }}

- name: Install pynetbox and testing packages.
run: pip install . black pytest
run: pip install . black==19.10b0 pytest

- name: Run Linter
run: black --check .
run: black --diff pynetbox tests

- name: Run Tests
run: pytest
Expand Down
4 changes: 2 additions & 2 deletions pynetbox/core/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def save(self):
if diff:
serialized = self.serialize()
req = Request(
key=self.id if not self.url else None,
key=self.id,
base=self.endpoint.url,
token=self.api.token,
session_key=self.api.session_key,
Expand Down Expand Up @@ -430,7 +430,7 @@ def delete(self):
>>>
"""
req = Request(
key=self.id if not self.url else None,
key=self.id,
base=self.endpoint.url,
token=self.api.token,
session_key=self.api.session_key,
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def test_nested_write(self):
"child": {
"id": 321,
"name": "test123",
"url": "http://localhost:8080/api/test-app/test-endpoint/",
"url": "http://localhost:8080/api/test-app/test-endpoint/321/",
},
},
app,
Expand All @@ -224,7 +224,7 @@ def test_nested_write(self):
test.child.save()
self.assertEqual(
app.http_session.patch.call_args[0][0],
"http://localhost:8080/api/test-app/test-endpoint/",
"http://localhost:8080/api/test-app/test-endpoint/321/",
)

def test_endpoint_from_url(self):
Expand Down

0 comments on commit c45411a

Please sign in to comment.