Skip to content

Commit

Permalink
Preliminary tests for Load tasks
Browse files Browse the repository at this point in the history
Why these changes are being introduced:

Load tasks will upsert data into Quickbase.  Before any actual Load Tasks
exist in this project, we have enough of a framework to create some tests
that simulate what Load Tasks will look like and test them a bit.

How this addresses that need:
* Creates tests in tests/test_load.py that sketch Load Tasks behavior

Side effects of this change:
* None

Relevant ticket(s):
* https://mitlibraries.atlassian.net/browse/HRQB-12
  • Loading branch information
ghukill committed May 2, 2024
1 parent 06acc1a commit 80aa0c8
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions tests/test_load.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# ruff: noqa: N803

import pytest

from hrqb.base import QuickbaseUpsertTask


def test_load_upsert_records_default_get_records_no_parent_error(
tmpdir,
mocked_table_name,
):
task = QuickbaseUpsertTask(
path=f"{tmpdir}/load__example_table_0.json",
table_name=mocked_table_name,
)
with pytest.raises(
ValueError, match="Expected a single input to this Task but found: 0"
):
task.get_records()


def test_load_upsert_records_default_get_records_returns_dict(
tmpdir,
quickbase_load_task_with_parent_data,
mocked_table_name,
mocked_upsert_data,
):
task = quickbase_load_task_with_parent_data(
path=f"{tmpdir}/load__example_table_0.json",
table_name=mocked_table_name,
)
assert task.get_records() == mocked_upsert_data


def test_load_upsert_records_task_run_success(
tmpdir,
quickbase_load_task_with_parent_data,
mocked_table_name,
mocked_qb_api_getAppTables,
mocked_qb_api_upsert,
):

task = quickbase_load_task_with_parent_data(
path=f"{tmpdir}/load__example_table_0.json",
table_name=mocked_table_name,
)
task.run()
assert task.complete()
assert task.output().read() == mocked_qb_api_upsert

0 comments on commit 80aa0c8

Please sign in to comment.