forked from openedx/aspects-dbt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Unit tests for dbt models (openedx#112)
* feat: new unit tests for dbt models and macros
- Loading branch information
1 parent
f8ba41c
commit e231fab
Showing
83 changed files
with
70,373 additions
and
285 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ target/ | |
dbt_packages/ | ||
logs/ | ||
coverage.json | ||
|
||
.DS_Store |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
{% macro generate_schema_name(custom_schema_name, node) -%} | ||
{{ generate_schema_name_for_env(custom_schema_name, node) }} | ||
|
||
{%- set default_schema = target.schema -%} | ||
{%- if ( | ||
target.name == "prod" or node.resource_type == "seed" | ||
) and custom_schema_name is not none -%} | ||
|
||
{{ custom_schema_name | trim }} | ||
|
||
{%- else -%} {{ default_schema }} | ||
|
||
{%- endif -%} | ||
|
||
{%- endmacro %} |
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
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,14 @@ | ||
unit_tests: | ||
- name: test_xapi_events_all_parsed | ||
model: xapi_events_all_parsed | ||
config: | ||
tags: 'ci' | ||
given: | ||
- input: source("xapi", "xapi_events_all") | ||
format: sql | ||
rows: | | ||
select * from xapi.xapi_events_all | ||
expect: | ||
format: sql | ||
rows: | | ||
select * from xapi_events_all_parsed_expected |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{{ | ||
config( | ||
materialized="materialized_view", | ||
schema=env_var("ASPECTS_EVENT_SINK_DATABASE", "event_sink"), | ||
engine=get_engine("ReplacingMergeTree()"), | ||
order_by="(location)", | ||
post_hook="OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL", | ||
) | ||
}} | ||
|
||
select | ||
location, | ||
display_name as block_name, | ||
toString(section) | ||
|| ':' | ||
|| toString(subsection) | ||
|| ':' | ||
|| toString(unit) | ||
|| ' - ' | ||
|| display_name as display_name_with_location, | ||
JSONExtractInt(xblock_data_json, 'section') as section, | ||
JSONExtractInt(xblock_data_json, 'subsection') as subsection, | ||
JSONExtractInt(xblock_data_json, 'unit') as unit, | ||
JSONExtractBool(xblock_data_json, 'graded') as graded, | ||
order as course_order, | ||
course_key, | ||
dump_id, | ||
time_last_dumped | ||
from {{ source("event_sink", "course_blocks") }} course_blocks | ||
join | ||
( | ||
select location, max(time_last_dumped) as max_time_last_dumped | ||
from {{ source("event_sink", "course_blocks") }} | ||
group by location | ||
) latest_course_blocks | ||
on course_blocks.location = latest_course_blocks.location | ||
and course_blocks.time_last_dumped = latest_course_blocks.max_time_last_dumped |
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
Oops, something went wrong.