-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from dbt-labs/clean_adding_pytest
Adding Pytest Tests
- Loading branch information
Showing
82 changed files
with
7,166 additions
and
3,425 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
@joellabes | ||
@callum-mcdata |
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,37 +1,28 @@ | ||
name: "End to end testing" | ||
description: "Set up profile and run dbt with test project" | ||
inputs: | ||
dbt-project: | ||
description: "Location of test project" | ||
required: false | ||
default: "integration_tests" | ||
dbt-target: | ||
dbt_target: | ||
description: "Name of target to use when running dbt" | ||
required: true | ||
database-adapter-package: | ||
description: "Name of database adapter to install" | ||
required: true | ||
|
||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
|
||
- name: Install python dependencies | ||
shell: bash | ||
run: | | ||
pip install --user --upgrade pip | ||
pip --version | ||
pip install -r dev-requirements.txt | ||
- name: Setup dbt profile | ||
shell: bash | ||
run: | | ||
mkdir -p $HOME/.dbt | ||
cp ${{ github.action_path }}/sample.profiles.yml $HOME/.dbt/profiles.yml | ||
pip install -r dev-requirements.txt | ||
- name: Run dbt | ||
## Make sure to defined dbt_target as an environment variable | ||
## Previously we were supplying just as an input and os.environ | ||
## wasn't able to recognize it. | ||
- name: Run pytest | ||
shell: bash | ||
env: | ||
dbt_target: ${{ inputs.dbt_target }} | ||
run: | | ||
cd ${{ inputs.dbt-project }} | ||
dbt deps --target ${{ inputs.dbt-target }} | ||
dbt seed --target ${{ inputs.dbt-target }} --full-refresh | ||
dbt build --target ${{ inputs.dbt-target }} --full-refresh | ||
python3 -m pytest tests/functional |
This file was deleted.
Oops, something went wrong.
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,4 +1,17 @@ | ||
git+https://github.com/dbt-labs/dbt-redshift.git@c35865b | ||
git+https://github.com/dbt-labs/dbt-snowflake.git@a017382 | ||
git+https://github.com/dbt-labs/dbt-bigquery.git@d52222e | ||
git+https://github.com/dbt-labs/dbt-core.git@0db634d#egg=dbt-core&subdirectory=core | ||
pytest | ||
pytest-dotenv | ||
|
||
# Bleeding edge | ||
# git+https://github.com/dbt-labs/dbt-core.git@main#egg=dbt-tests-adapter&subdirectory=tests/adapter | ||
# git+https://github.com/dbt-labs/dbt-core.git@main#egg=dbt-core&subdirectory=core | ||
# git+https://github.com/dbt-labs/dbt-core.git@main#egg=dbt-postgres&subdirectory=plugins/postgres | ||
# git+https://github.com/dbt-labs/dbt-redshift.git | ||
# git+https://github.com/dbt-labs/dbt-snowflake.git | ||
# git+https://github.com/dbt-labs/dbt-bigquery.git | ||
|
||
# Most recent release candidates | ||
dbt-tests-adapter==1.2.0 | ||
dbt-core==1.2.0 | ||
dbt-redshift==1.2.0 | ||
dbt-snowflake==1.2.0 | ||
dbt-bigquery==1.2.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
version: "3.5" | ||
services: | ||
database: | ||
image: postgres | ||
environment: | ||
POSTGRES_USER: "root" | ||
POSTGRES_PASSWORD: "password" | ||
POSTGRES_DB: "dbt" | ||
ports: | ||
- "5432:5432" | ||
|
||
networks: | ||
default: | ||
name: dbt-net |
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
22 changes: 10 additions & 12 deletions
22
integration_tests/models/metric_definitions/base_count_metric.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 |
---|---|---|
@@ -1,14 +1,12 @@ | ||
version: 2 | ||
metrics: | ||
- name: base_count_metric | ||
label: Members of Community Slack | ||
model: ref('seed_slack_users') | ||
|
||
type: count | ||
sql: "*" | ||
timestamp: joined_at | ||
time_grains: [day, week, month] | ||
|
||
dimensions: | ||
- is_active_past_quarter | ||
- has_messaged | ||
- name: base_count_metric | ||
model: ref('fact_orders') | ||
label: Total Discount ($) | ||
timestamp: order_date | ||
time_grains: [day, week, month] | ||
type: count | ||
sql: order_total | ||
dimensions: | ||
- had_discount | ||
- order_country |
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
2 changes: 1 addition & 1 deletion
2
integration_tests/models/metric_testing_models/base_average_metric.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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
select * | ||
from | ||
{{ metrics.calculate(metric('base_average_metric'), | ||
grain='day', | ||
grain='month', | ||
dimensions=['had_discount']) | ||
}} |
6 changes: 6 additions & 0 deletions
6
integration_tests/models/metric_testing_models/base_count_distinct_metric.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,6 @@ | ||
select * | ||
from | ||
{{ metrics.calculate(metric('base_count_distinct_metric'), | ||
grain='month' | ||
) | ||
}} |
18 changes: 18 additions & 0 deletions
18
integration_tests/models/metric_testing_models/base_count_distinct_metric.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 @@ | ||
version: 2 | ||
models: | ||
- name: base_count_distinct_metric | ||
tests: | ||
- dbt_utils.equality: | ||
compare_model: ref('base_count_distinct_metric__expected') | ||
|
||
metrics: | ||
- name: base_count_distinct_metric | ||
model: ref('fact_orders') | ||
label: Count Distinct | ||
timestamp: order_date | ||
time_grains: [day, week, month] | ||
type: count_distinct | ||
sql: customer_id | ||
dimensions: | ||
- had_discount | ||
- order_country |
Oops, something went wrong.