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

Adds quote parameter to accepted_values test #1874

Closed
wants to merge 7 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% macro test_accepted_values(model, values) %}

{% set column_name = kwargs.get('column_name', kwargs.get('field')) %}
{% set quote_values = kwargs.get('quote', True) %}

with all_values as (

Expand All @@ -20,9 +21,12 @@ validation_errors as (
from all_values
where value_field not in (
{% for value in values -%}

'{{ value }}' {% if not loop.last -%} , {%- endif %}

{% if quote_values -%}
'{{ value }}'
{%- else -%}
{{ value }}
{%- endif -%}
{%- if not loop.last -%},{%- endif %}
{%- endfor %}
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ models:
- name: favorite_color
description: "The user's favorite color"
tests:
- accepted_values: { values: ['blue', 'green'] }
- accepted_values: { values: ['blue', 'green'], quote: true }
- name: fav_number
description: "The user's favorite number"
tests:
- accepted_values:
values: [3.14159265]
quote: false


- name: table_summary
description: "The summary table"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_postgres_schema_tests(self):
self.assertEqual(len(results), 5)
test_results = self.run_schema_validations()
# If the disabled model's tests ran, there would be 19 of these.
self.assertEqual(len(test_results), 18)
self.assertEqual(len(test_results), 19)

for result in test_results:
# assert that all deliberately failing tests actually fail
Expand Down