Skip to content

Commit

Permalink
Fix flaky integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mesozoic committed Sep 17, 2024
1 parent d0000c5 commit 440491a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions pyairtable/orm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ def __bool__(self) -> bool:
"Model.save() now returns SaveResult instead of bool; switch"
" to checking Model.save().created instead before the 4.0 release.",
DeprecationWarning,
stacklevel=2,
)
return self.created

Expand Down
1 change: 1 addition & 0 deletions pyairtable/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def attachment(url: str, filename: str = "") -> CreateAttachmentByUrl:
warnings.warn(
"attachment(url, filename) is deprecated; use {'url': url, 'filename': filename} instead.",
DeprecationWarning,
stacklevel=2,
)
return {"url": url} if not filename else {"url": url, "filename": filename}

Expand Down
9 changes: 8 additions & 1 deletion tests/integration/test_integration_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,14 @@ def test_integration_formula_composition(table: Table, cols):
def test_integration_attachment(table, cols, valid_img_url):
rec = table.create({cols.ATTACHMENT: [{"url": valid_img_url}]})
rv_get = table.get(rec["id"])
assert rv_get["fields"]["attachment"][0]["url"].endswith("logo.png")
att = rv_get["fields"]["attachment"][0]
assert att["filename"] in (
valid_img_url.rpartition("/")[-1], # sometimes taken from URL
"a." + valid_img_url.rpartition(".")[-1], # default if not
)
original = requests.get(valid_img_url).content
attached = requests.get(att["url"]).content
assert original == attached


def test_integration_attachment_multiple(table, cols, valid_img_url):
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/test_integration_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,11 @@ def test_integration_orm(Contact, Address):
)

assert contact.first_name == "John"
assert contact.save()
assert contact.save().created
assert contact.id

contact.first_name = "Not Gui"
assert not contact.save()
assert not contact.save().created

rv_address = contact.address[0]
assert rv_address.exists()
Expand Down

0 comments on commit 440491a

Please sign in to comment.