Skip to content

Commit

Permalink
Test Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
gtalarico committed Aug 8, 2021
1 parent 0bf46ae commit aca0f01
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ clean:
rm -rdf ./docs/build
rm -rdf ./dist
rm -rdf ./build
rm -rdf ./htmlcov
rm -rdf pyairtable.egg-info
rm -rdf .pytest_cache

30 changes: 30 additions & 0 deletions tests/test_api_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,36 @@ def test_all(table, mock_response_list, mock_records):
assert dict_equals(resp, mock_records[n])


def test_iterate(table, mock_response_list, mock_records):
with Mocker() as mock:

mock.get(
table.table_url,
status_code=200,
json=mock_response_list[0],
complete_qs=True,
)
for n, resp in enumerate(mock_response_list, 1):
offset = resp.get("offset", None)
if not offset:
continue
params = {"offset": offset}
offset_url = Request("get", table.table_url, params=params).prepare().url
mock.get(
offset_url,
status_code=200,
json=mock_response_list[1],
complete_qs=True,
)

pages = []
for page in table.iterate():
pages.append(page)

for n, response in enumerate(mock_response_list):
assert seq_equals(pages[n], response["records"])


def test_create(table, mock_response_single):
with Mocker() as mock:
post_data = mock_response_single["fields"]
Expand Down
1 change: 0 additions & 1 deletion tests/test_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ class Meta:

assert m_delete.called

# to_record (split)
record = contact.to_record()
assert record["id"] == contact.id
assert record["createdTime"] == contact.created_time
Expand Down

0 comments on commit aca0f01

Please sign in to comment.