From fc98e4e30cd299ddd67c43902f2a5efa9511edfb Mon Sep 17 00:00:00 2001 From: Grace Goheen <53586774+graciegoheen@users.noreply.github.com> Date: Wed, 22 May 2024 15:07:04 -0600 Subject: [PATCH] update tests: -> data_tests: (#893) * update tests: -> data_tests: * bump require-dbt-version * undo change to require-dbt-version * Update README.md --------- Co-authored-by: Doug Beatty <44704949+dbeatty10@users.noreply.github.com> --- README.md | 2 +- .../data/schema_tests/schema.yml | 4 +- integration_tests/models/datetime/schema.yml | 2 +- .../models/generic_tests/schema.yml | 50 +++++------ integration_tests/models/geo/schema.yml | 4 +- integration_tests/models/sql/schema.yml | 88 +++++++++---------- integration_tests/models/web/schema.yml | 6 +- 7 files changed, 78 insertions(+), 78 deletions(-) diff --git a/README.md b/README.md index fa9e8126..9dd888e2 100644 --- a/README.md +++ b/README.md @@ -615,7 +615,7 @@ Certain tests support the optional `group_by_columns` argument to provide more g - Some data checks can only be expressed within a group (e.g. ID values should be unique within a group but can be repeated between groups) - Some data checks are more precise when done by group (e.g. not only should table rowcounts be equal but the counts within each group should be equal) -This feature is currently available for the following tests: +This feature is currently available for the following data tests: - equal_rowcount() - fewer_rows_than() diff --git a/integration_tests/data/schema_tests/schema.yml b/integration_tests/data/schema_tests/schema.yml index ed4068d0..7b57a911 100644 --- a/integration_tests/data/schema_tests/schema.yml +++ b/integration_tests/data/schema_tests/schema.yml @@ -4,7 +4,7 @@ seeds: - name: data_test_sequential_values columns: - name: my_even_sequence - tests: + data_tests: - dbt_utils.sequential_values: interval: 2 - dbt_utils.sequential_values: @@ -15,7 +15,7 @@ seeds: - name: data_test_sequential_timestamps columns: - name: my_timestamp - tests: + data_tests: - dbt_utils.sequential_values: interval: 1 datepart: 'hour' diff --git a/integration_tests/models/datetime/schema.yml b/integration_tests/models/datetime/schema.yml index dbc3431c..82e813f5 100644 --- a/integration_tests/models/datetime/schema.yml +++ b/integration_tests/models/datetime/schema.yml @@ -2,6 +2,6 @@ version: 2 models: - name: test_date_spine - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_date_spine') diff --git a/integration_tests/models/generic_tests/schema.yml b/integration_tests/models/generic_tests/schema.yml index 022b0a59..cecb9c3f 100644 --- a/integration_tests/models/generic_tests/schema.yml +++ b/integration_tests/models/generic_tests/schema.yml @@ -4,7 +4,7 @@ seeds: - name: data_test_not_constant columns: - name: field - tests: + data_tests: - dbt_utils.not_constant - dbt_utils.not_constant: group_by_columns: ['col_a'] @@ -12,13 +12,13 @@ seeds: - name: data_test_at_least_one columns: - name: field - tests: + data_tests: - dbt_utils.at_least_one - dbt_utils.at_least_one: group_by_columns: ['field'] - name: data_test_expression_is_true - tests: + data_tests: - dbt_utils.expression_is_true: expression: col_a + col_b = 1 - dbt_utils.expression_is_true: @@ -27,11 +27,11 @@ seeds: where: col_b = 0.5 columns: - name: col_a - tests: + data_tests: - dbt_utils.expression_is_true: expression: + col_b = 1 - name: col_b - tests: + data_tests: - dbt_utils.expression_is_true: expression: = 0.5 config: @@ -40,7 +40,7 @@ seeds: - name: data_people columns: - name: is_active - tests: + data_tests: - dbt_utils.cardinality_equality: field: is_active to: ref('data_people') @@ -48,28 +48,28 @@ seeds: - name: data_test_not_accepted_values columns: - name: city - tests: + data_tests: - dbt_utils.not_accepted_values: values: ['Madrid', 'Berlin'] - name: data_test_relationships_where_table_2 columns: - name: id - tests: + data_tests: - dbt_utils.relationships_where: to: ref('data_test_relationships_where_table_1') field: id from_condition: id <> 4 - name: data_test_mutually_exclusive_ranges_no_gaps - tests: + data_tests: - dbt_utils.mutually_exclusive_ranges: lower_bound_column: lower_bound upper_bound_column: upper_bound gaps: not_allowed - name: data_test_mutually_exclusive_ranges_with_gaps - tests: + data_tests: - dbt_utils.mutually_exclusive_ranges: lower_bound_column: valid_from upper_bound_column: coalesce(valid_to, '2099-01-01') @@ -83,7 +83,7 @@ seeds: gaps: required - name: data_test_mutually_exclusive_ranges_with_gaps_zero_length - tests: + data_tests: - dbt_utils.mutually_exclusive_ranges: lower_bound_column: valid_from upper_bound_column: valid_to @@ -91,7 +91,7 @@ seeds: zero_length_range_allowed: true - name: data_unique_combination_of_columns - tests: + data_tests: - dbt_utils.unique_combination_of_columns: combination_of_columns: - month @@ -100,7 +100,7 @@ seeds: - name: data_cardinality_equality_a columns: - name: same_name - tests: + data_tests: - dbt_utils.cardinality_equality: to: ref('data_cardinality_equality_b') field: same_name @@ -111,7 +111,7 @@ seeds: - name: data_test_accepted_range columns: - name: id - tests: + data_tests: - dbt_utils.accepted_range: min_value: -1 max_value: 11 @@ -130,7 +130,7 @@ seeds: - name: data_not_null_proportion columns: - name: point_5 - tests: + data_tests: - dbt_utils.not_null_proportion: at_least: 0.5 at_most: 0.5 @@ -138,12 +138,12 @@ seeds: at_least: 0 group_by_columns: ['point_9'] - name: point_9 - tests: + data_tests: - dbt_utils.not_null_proportion: at_least: 0.9 - name: data_test_equality_a - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_test_equality_a') - dbt_utils.equality: @@ -161,7 +161,7 @@ seeds: - col_c - name: data_test_equality_floats_a - tests: + data_tests: # test precision only - dbt_utils.equality: compare_model: ref('data_test_equality_floats_b') @@ -173,7 +173,7 @@ seeds: warn_if: "<0" - name: data_test_equality_floats_columns_a - tests: + data_tests: # Positive assertion tests - dbt_utils.equality: compare_model: ref('data_test_equality_floats_columns_b') @@ -195,7 +195,7 @@ seeds: models: - name: recency_time_included - tests: + data_tests: - dbt_utils.recency: datepart: day field: created_at @@ -212,7 +212,7 @@ models: group_by_columns: ['col1', 'col2'] - name: recency_time_excluded - tests: + data_tests: - dbt_utils.recency: datepart: day field: created_at @@ -227,7 +227,7 @@ models: warn_if: "<0" - name: test_equal_rowcount - tests: + data_tests: - dbt_utils.equal_rowcount: compare_model: ref('test_equal_rowcount') - dbt_utils.equal_rowcount: @@ -235,7 +235,7 @@ models: group_by_columns: ['field'] - name: test_equal_column_subset - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_people') compare_columns: @@ -244,7 +244,7 @@ models: - email - name: test_fewer_rows_than - tests: + data_tests: - dbt_utils.fewer_rows_than: compare_model: ref('data_test_fewer_rows_than_table_2') - dbt_utils.fewer_rows_than: @@ -252,7 +252,7 @@ models: group_by_columns: ['col_a'] - name: equality_less_columns - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_test_equality_a') exclude_columns: diff --git a/integration_tests/models/geo/schema.yml b/integration_tests/models/geo/schema.yml index 50dd0241..31cc6a72 100644 --- a/integration_tests/models/geo/schema.yml +++ b/integration_tests/models/geo/schema.yml @@ -2,12 +2,12 @@ version: 2 models: - name: test_haversine_distance_km - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_haversine_distance_mi - tests: + data_tests: - assert_equal: actual: actual expected: expected diff --git a/integration_tests/models/sql/schema.yml b/integration_tests/models/sql/schema.yml index e79e782f..0103ceee 100644 --- a/integration_tests/models/sql/schema.yml +++ b/integration_tests/models/sql/schema.yml @@ -2,7 +2,7 @@ version: 2 models: - name: test_get_single_value - tests: + data_tests: - assert_equal: actual: date_actual expected: date_expected @@ -17,7 +17,7 @@ models: expected: string_expected - name: test_get_single_value_default - tests: + data_tests: - assert_equal: actual: date_actual expected: date_expected @@ -32,71 +32,71 @@ models: expected: string_expected - name: test_generate_series - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_generate_series') - name: test_get_column_values columns: - name: count_a - tests: + data_tests: - accepted_values: values: - '1' - name: count_b - tests: + data_tests: - accepted_values: values: - '1' - name: count_c - tests: + data_tests: - accepted_values: values: - '1' - name: count_d - tests: + data_tests: - accepted_values: values: - '1' - name: count_e - tests: + data_tests: - accepted_values: values: - '1' - name: count_f - tests: + data_tests: - accepted_values: values: - '1' - name: count_g - tests: + data_tests: - accepted_values: values: - '5' - name: test_get_column_values_where - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_get_column_values_where_expected') - name: test_get_filtered_columns_in_relation - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_filtered_columns_in_relation_expected') - name: test_get_relations_by_prefix_and_union columns: - name: event - tests: + data_tests: - not_null - name: user_id - tests: + data_tests: - dbt_utils.at_least_one - not_null - unique @@ -104,94 +104,94 @@ models: - name: test_nullcheck_table columns: - name: field_1 - tests: + data_tests: - not_empty_string - name: field_2 - tests: + data_tests: - not_empty_string - name: field_3 - tests: + data_tests: - not_empty_string - name: test_safe_add - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_safe_subtract - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_safe_divide - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_pivot - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_pivot_expected') - name: test_pivot_apostrophe - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_pivot_expected_apostrophe') - name: test_unpivot_original_api - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_unpivot_original_api_expected') - name: test_unpivot - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_unpivot_expected') - name: test_unpivot_bool - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_unpivot_bool_expected') - name: test_star - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_star_expected') - name: test_star_quote_identifiers - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_star_prefix_suffix - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_star_prefix_suffix_expected') - name: test_star_aggregate - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_star_aggregate_expected') - name: test_star_uppercase - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_star_expected') - name: test_star_no_columns columns: - name: canary_column #If the no-columns state isn't hit, this table won't be queryable because there will be a missing comma - tests: + data_tests: - not_null - name: test_generate_surrogate_key - tests: + data_tests: - assert_equal: actual: actual_column_1_only expected: expected_column_1_only @@ -200,49 +200,49 @@ models: expected: expected_all_columns - name: test_union - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_union_expected') - name: test_union_where columns: - name: id - tests: + data_tests: - dbt_utils.expression_is_true: expression: "= 1" - name: favorite_number - tests: + data_tests: - dbt_utils.not_constant - name: test_union_no_source_column - tests: + data_tests: - expect_table_columns_to_match_set: column_list: ["id", "name", "favorite_color", "favorite_number"] - name: test_union_exclude_lowercase - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_union_exclude_expected') - name: test_union_exclude_uppercase - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_union_exclude_expected') - name: test_get_relations_by_pattern - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_union_events_expected') - name: test_deduplicate - tests: + data_tests: - dbt_utils.equality: compare_model: ref('data_deduplicate_expected') - name: test_not_empty_string_failing columns: - name: string_trim_whitespace_true - tests: + data_tests: - dbt_utils.not_empty_string: config: severity: error @@ -252,15 +252,15 @@ models: - name: test_not_empty_string_passing columns: - name: string_trim_whitespace_true - tests: + data_tests: - dbt_utils.not_empty_string - name: string_trim_whitespace_false - tests: + data_tests: - dbt_utils.not_empty_string: trim_whitespace: false - name: test_width_bucket - tests: + data_tests: - assert_equal: actual: actual expected: expected diff --git a/integration_tests/models/web/schema.yml b/integration_tests/models/web/schema.yml index 53776bd8..7f02b317 100644 --- a/integration_tests/models/web/schema.yml +++ b/integration_tests/models/web/schema.yml @@ -2,19 +2,19 @@ version: 2 models: - name: test_urls - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_url_host - tests: + data_tests: - assert_equal: actual: actual expected: expected - name: test_url_path - tests: + data_tests: - assert_equal: actual: actual expected: expected \ No newline at end of file