-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a happy path project fixture (#10291)
- Loading branch information
1 parent
e977b3e
commit e699f5d
Showing
24 changed files
with
199 additions
and
79 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
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
Empty file.
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,32 @@ | ||
import os | ||
from distutils.dir_util import copy_tree | ||
|
||
import pytest | ||
|
||
|
||
def delete_files_in_directory(directory_path): | ||
try: | ||
with os.scandir(directory_path) as entries: | ||
for entry in entries: | ||
if entry.is_file(): | ||
os.unlink(entry.path) | ||
print("All files deleted successfully.") | ||
except OSError: | ||
print("Error occurred while deleting files.") | ||
|
||
|
||
@pytest.fixture(scope="class") | ||
def happy_path_project_files(project_root): | ||
# copy fixture files to the project root | ||
delete_files_in_directory(project_root) | ||
copy_tree( | ||
os.path.dirname(os.path.realpath(__file__)) + "/happy_path_project", str(project_root) | ||
) | ||
|
||
|
||
# We do project_setup first because it will write out a dbt_project.yml. | ||
# This file will be overwritten by the files in happy_path_project later on. | ||
@pytest.fixture(scope="class") | ||
def happy_path_project(project_setup, happy_path_project_files): | ||
# A fixture that gives functional test the project living in happy_path_project | ||
return project_setup |
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 @@ | ||
select 4 as id |
17 changes: 17 additions & 0 deletions
17
tests/functional/fixtures/happy_path_project/dbt_project.yml
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,17 @@ | ||
analysis-paths: | ||
- analyses | ||
config-version: 2 | ||
flags: | ||
send_anonymous_usage_stats: false | ||
macro-paths: | ||
- macros | ||
name: test | ||
profile: test | ||
seed-paths: | ||
- seeds | ||
seeds: | ||
quote_columns: false | ||
snapshot-paths: | ||
- snapshots | ||
test-paths: | ||
- tests |
7 changes: 7 additions & 0 deletions
7
tests/functional/fixtures/happy_path_project/macros/macro_stuff.sql
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,7 @@ | ||
{% macro cool_macro() %} | ||
wow! | ||
{% endmacro %} | ||
|
||
{% macro other_cool_macro(a, b) %} | ||
cool! | ||
{% 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% docs my_docs %} | ||
some docs | ||
{% enddocs %} |
5 changes: 5 additions & 0 deletions
5
tests/functional/fixtures/happy_path_project/models/ephemeral.sql
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,5 @@ | ||
{{ config(materialized='ephemeral') }} | ||
|
||
select | ||
1 as id, | ||
{{ dbt.date_trunc('day', dbt.current_timestamp()) }} as created_at |
12 changes: 12 additions & 0 deletions
12
tests/functional/fixtures/happy_path_project/models/incremental.sql
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,12 @@ | ||
{{ | ||
config( | ||
materialized = "incremental", | ||
incremental_strategy = "delete+insert", | ||
) | ||
}} | ||
|
||
select * from {{ ref('seed') }} | ||
|
||
{% if is_incremental() %} | ||
where a > (select max(a) from {{this}}) | ||
{% endif %} |
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,7 @@ | ||
metrics: | ||
- name: total_outer | ||
type: simple | ||
description: The total count of outer | ||
label: Total Outer | ||
type_params: | ||
measure: total_outer_count |
2 changes: 2 additions & 0 deletions
2
tests/functional/fixtures/happy_path_project/models/metricflow_time_spine.sql
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,2 @@ | ||
select | ||
{{ dbt.date_trunc('day', dbt.current_timestamp()) }} as date_day |
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 @@ | ||
select * from {{ ref('ephemeral') }} |
15 changes: 15 additions & 0 deletions
15
tests/functional/fixtures/happy_path_project/models/schema.yml
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,15 @@ | ||
version: 2 | ||
models: | ||
- name: outer | ||
description: The outer table | ||
columns: | ||
- name: id | ||
description: The id value | ||
data_tests: | ||
- unique | ||
- not_null | ||
|
||
sources: | ||
- name: my_source | ||
tables: | ||
- name: my_table |
18 changes: 18 additions & 0 deletions
18
tests/functional/fixtures/happy_path_project/models/sm.yml
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,18 @@ | ||
semantic_models: | ||
- name: my_sm | ||
model: ref('outer') | ||
defaults: | ||
agg_time_dimension: created_at | ||
entities: | ||
- name: my_entity | ||
type: primary | ||
expr: id | ||
dimensions: | ||
- name: created_at | ||
type: time | ||
type_params: | ||
time_granularity: day | ||
measures: | ||
- name: total_outer_count | ||
agg: count | ||
expr: 1 |
14 changes: 14 additions & 0 deletions
14
tests/functional/fixtures/happy_path_project/models/sq.yml
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 @@ | ||
saved_queries: | ||
- name: my_saved_query | ||
label: My Saved Query | ||
query_params: | ||
metrics: | ||
- total_outer | ||
group_by: | ||
- "Dimension('my_entity__created_at')" | ||
exports: | ||
- name: my_export | ||
config: | ||
alias: my_export_alias | ||
export_as: table | ||
schema: my_export_schema_name |
1 change: 1 addition & 0 deletions
1
tests/functional/fixtures/happy_path_project/models/sub/inner.sql
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 @@ | ||
select * from {{ ref('outer') }} |
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,2 @@ | ||
a,b | ||
1,2 |
12 changes: 12 additions & 0 deletions
12
tests/functional/fixtures/happy_path_project/snapshots/snapshot.sql
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,12 @@ | ||
{% snapshot my_snapshot %} | ||
{{ | ||
config( | ||
target_database=var('target_database', database), | ||
target_schema=schema, | ||
unique_key='id', | ||
strategy='timestamp', | ||
updated_at='updated_at', | ||
) | ||
}} | ||
select * from {{database}}.{{schema}}.seed | ||
{% endsnapshot %} |
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 @@ | ||
select 1 as id limit 0 |
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.