Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DBT-681: adding test-case for jaffle_shop example #156

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/fixtures/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# fixtures directory
101 changes: 101 additions & 0 deletions tests/fixtures/dbt_integration_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import pytest

dbt_integration_project__my_macros_sql = """


{% macro do_something(foo, bar) %}

select
'{{ foo }}'::text as foo,
'{{ bar }}'::text as bar

{% endmacro %}

"""


dbt_integration_project__incremental_sql = """

-- TODO : add dist/sort keys
{{
config(
materialized = 'incremental',
unique_key = 'id',
)
}}


select * from {{ this.schema }}.seed

{% if is_incremental() %}
where updated_at > (select max(updated_at) from {{ this }})
{% endif %}
"""


dbt_integration_project__schema_yml = """
version: 2
models:
- name: table_model
columns:
- name: id
tests:
- unique
"""


dbt_integration_project__table_model_sql = """

-- TODO : add dist/sort keys
{{
config(
materialized = 'table',
)
}}

select * from {{ this.schema }}.seed
"""

dbt_integration_project__view_model_sql = """
{{
config(
materialized = 'view',
)
}}

select * from {{ this.schema }}.seed
"""


dbt_integration_project__dbt_project_yml = """
name: dbt_integration_project
version: '1.0'
config-version: 2

model-paths: ["models"] # paths to models
analysis-paths: ["analyses"] # path with analysis files which are compiled, but not run
target-path: "target" # path for compiled code
clean-targets: ["target"] # directories removed by the clean task
test-paths: ["tests"] # where to store test results
seed-paths: ["seeds"] # load CSVs from this directory with `dbt seed`
macro-paths: ["macros"] # where to find macros

profile: user

models:
dbt_integration_project:
"""


@pytest.fixture(scope="class")
def dbt_integration_project():
return {
"dbt_project.yml": dbt_integration_project__dbt_project_yml,
"macros": {"my_macros.sql": dbt_integration_project__my_macros_sql},
"models": {
"incremental.sql": dbt_integration_project__incremental_sql,
"schema.yml": dbt_integration_project__schema_yml,
"table_model.sql": dbt_integration_project__table_model_sql,
"view_model.sql": dbt_integration_project__view_model_sql,
},
}
Loading