At the moment we still need a lot of repetitive code to define our tests: Each from_mocks call needs to specify all the input table mocks even if their data would not change between tests.
What changed
We added a default_inputs argument to the table_meta decorator. This allows to pass reasonable default to the model.
Here is an example from the docs:
@table_meta(
query_path="./examples/test_query.sql",
default_inputs=[UserTable([]), SubscriptionTable([])] # We can provide defaults for the class if needed.
)
class MultipleSubscriptionUsersTable(BigQueryMockTable):
user_id = col.Int(default=1)
# Setting up different scenarios to demonstrate the use of defaults
users = UserTable.from_dicts([{"user_id": 1}, {"user_id": 2}])
subscriptions = SubscriptionTable.from_dicts(
[
{"subscription_id": 1, "user_id": 1},
{"subscription_id": 2, "user_id": 1},
{"subscription_id": 2, "user_id": 2},
]
)
# Utilizing the default inputs set in the table_meta
res = MultipleSubscriptionUsersTable.from_mocks(input_data=[])
res = MultipleSubscriptionUsersTable.from_mocks(input_data=[users]) # Using only users, defaults for others
res = MultipleSubscriptionUsersTable.from_mocks(input_data=[users, subscriptions]) # Overriding defaults
What to look for
You can ignore the changes in docs/ since they are auto generated from the docsource/ markdown file changes.
Instead, have a look at:
What do you think about the "API" of providing defaults this way
Problem
At the moment we still need a lot of repetitive code to define our tests: Each
from_mocks
call needs to specify all the input table mocks even if their data would not change between tests.What changed
We added a
default_inputs
argument to thetable_meta
decorator. This allows to pass reasonable default to the model. Here is an example from the docs:What to look for
You can ignore the changes in
docs/
since they are auto generated from thedocsource/
markdown file changes.Instead, have a look at: