-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm deprecation; add unit test for op usage
- Loading branch information
Showing
3 changed files
with
45 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
python_modules/libraries/dagster-embedded-elt/dagster_embedded_elt_tests/test_op.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import logging | ||
|
||
from dagster import OpExecutionContext, job, op | ||
from dagster_embedded_elt.sling import SlingReplicationParam | ||
from dagster_embedded_elt.sling.resources import SlingConnectionResource, SlingResource | ||
|
||
|
||
def test_base_sling_config_op( | ||
csv_to_sqlite_replication_config: SlingReplicationParam, | ||
path_to_temp_sqlite_db: str, | ||
): | ||
sling_resource = SlingResource( | ||
connections=[ | ||
SlingConnectionResource(type="file", name="SLING_FILE"), | ||
SlingConnectionResource( | ||
type="sqlite", | ||
name="SLING_SQLITE", | ||
connection_string=f"sqlite://{path_to_temp_sqlite_db}", | ||
), | ||
] | ||
) | ||
|
||
@op(out={}) | ||
def my_sling_op_yield_events(context: OpExecutionContext, sling: SlingResource): | ||
for row in sling.replicate( | ||
context=context, replication_config=csv_to_sqlite_replication_config | ||
): | ||
logging.info(row) | ||
|
||
@job | ||
def my_sling_op_yield_events_job(): | ||
my_sling_op_yield_events() | ||
|
||
result = my_sling_op_yield_events_job.execute_in_process(resources={"sling": sling_resource}) | ||
assert result.success |