Add Tap Test Runner and Test Template classes #580
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Migrated from GitLab: https://gitlab.com/meltano/sdk/-/merge_requests/197
Originally created by @stkbailey on 2021-10-27 19:41:01
Note: Content edited 11/13 with updated approach.
This MR addresses #259.
This MR creates new two object types in the SDK: the
TapTestRunner
and theTestTemplate
object. These can be used in conjunction to automatically test taps based on properties of the Tap, Stream, and Stream Attribute. It also updates the utility functionget_standard_tap_tests
to leverage the test templates, and adds functionality for easily parameterizing pytest (rather looping through a bunch of tests).TestTemplate
The TestTemplate object provides a standardized interface for building tap-related tests. Each of the tests must have
id
,name
, andrequired_args
properties, and arun_test
method. Any number of keyword arguments can be passed in when initializing the tests, but only the required arguments will be added as properties that can be referenced in therun_test()
method.There are currently templates for tap, stream, and attribute level tests.
TapTestRunner
The Test Runner object is a convenience class designed to make it easy to access sync messages and generate "default tests" from the SDK classes. Generally what a user would do is initialize the runner, perform a sync, then generate tests.
Example
In general, users would want to extract some initialized test objects through the
get_standard_tap_pytest_parameters
function, and then simply run them. This can be used to generate the tap-level, schema-level, or attribute-level tests.The map of this MR is shown below:
--- original approach [included for posterity] ---
The initial approach chosen here creates a utility class that will run a tap and capture its output to a couple of fields. The goal is to make it very easy for developers to get access to a set of records from their tap, so that they can evaluate the actual data content against expectations.
An implementation in a real tap might look something like this:
I am very open to suggestions on how to implement or refine this. Some question
raw
,records
,schema_messages
,state_messages
attributes sufficient?get_standard_tap_tests
functionality?test_primary_keys_are_not_null
,test_replication_key_is_valid
type of things?