Skip to content

Commit

Permalink
Tidy get calls to make testing easier
Browse files Browse the repository at this point in the history
Chaining the `get` calls would mean a messy amount of Mocks. Just use a
single `get` call and if it's empty return a dummy struct for sanity's
sake.

Also `get('name')` on the returned struct since we run into issues with
Mocking without it.

Fixes iamjackg#117
  • Loading branch information
nate-woythaler committed Nov 14, 2023
1 parent 3bbc5e3 commit cb62db9
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions md2cf/upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,9 @@ def labels_need_updating(page, existing_page):

if sorted(
[
label.name
for label in existing_page.get("metadata", {})
.get("labels", {})
.get("results", {})
# Use `get()` here for unit test sanity -- `Mock().name` is reserved.
label.get("name")
for label in existing_page.get("metadata", {"labels": {"results": {}}})
]
) != sorted(page.labels):
return True
Expand Down

0 comments on commit cb62db9

Please sign in to comment.