-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Tests for get_powers_of_two macro
Running into an issue where get_powersof_two is complaining that it's getting a string for the `uppoer_bound` variable, and I don't know why. Error: ``` E dbt.exceptions.CaughtMacroErrorWithNodeError: Compilation Error in model test_get_powers_of_two (models/test_get_powers_of_two.sql) E '<=' not supported between instances of 'str' and 'int' E E > in macro get_powers_of_two (macros/utils/generate_series.sql) E > called by model test_get_powers_of_two (models/test_get_powers_of_two.sql) ```
- Loading branch information
Showing
2 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
tests/adapter/dbt/tests/adapter/utils/fixture_get_powers_of_two.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,39 @@ | ||
# dateadd | ||
|
||
seeds__data_get_powers_of_two_csv = """upper_bound,result | ||
1,1 | ||
4,2 | ||
27,5 | ||
256,8 | ||
3125,12 | ||
46656,16 | ||
823543,20 | ||
16777216,24 | ||
387420489,29 | ||
""" | ||
|
||
|
||
models__test_get_powers_of_two_sql = """ | ||
with data as ( | ||
select | ||
cast({{ 'upper_bound' }} as {{ type_int() }}) as upper_bound, | ||
cast({{ 'result' }} as {{ type_int() }}) as result | ||
from {{ ref('data_get_powers_of_two') }} | ||
) | ||
select | ||
{{get_powers_of_two('upper_bound')}} as actual, | ||
result as expected | ||
from data | ||
""" | ||
|
||
models__test_get_powers_of_two_yml = """ | ||
version: 2 | ||
models: | ||
- name: test_powers_of_two | ||
tests: | ||
- assert_equal: | ||
actual: actual | ||
expected: expected | ||
""" |
26 changes: 26 additions & 0 deletions
26
tests/adapter/dbt/tests/adapter/utils/test_get_powers_of_two.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,26 @@ | ||
import pytest | ||
from dbt.tests.adapter.utils.base_utils import BaseUtils | ||
from dbt.tests.adapter.utils.fixture_get_powers_of_two import ( | ||
seeds__data_get_powers_of_two_csv, | ||
models__test_get_powers_of_two_sql, | ||
models__test_get_powers_of_two_yml, | ||
) | ||
|
||
|
||
class BaseGetPowersOfTwo(BaseUtils): | ||
@pytest.fixture(scope="class") | ||
def seeds(self): | ||
return {"data_get_powers_of_two.csv": seeds__data_get_powers_of_two_csv} | ||
|
||
@pytest.fixture(scope="class") | ||
def models(self): | ||
return { | ||
"test_get_powers_of_two.yml": models__test_get_powers_of_two_yml, | ||
"test_get_powers_of_two.sql": self.interpolate_macro_namespace( | ||
models__test_get_powers_of_two_sql, "get_powers_of_two" | ||
), | ||
} | ||
|
||
|
||
class TestGetPowersOfTwo(BaseGetPowersOfTwo): | ||
pass |