Skip to content

Commit f9692bd

Browse files
committed
chore: addressing minor inconsistencies
1 parent 2defd5c commit f9692bd

8 files changed

Lines changed: 104 additions & 31 deletions

File tree

.gitignore

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,15 @@ cython_debug/
205205
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
206206
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
207207
# and can be added to the global gitignore or merged into this file. However, if you prefer,
208-
# you could uncomment the following to ignore the entire vscode folder
209-
# .vscode/
208+
# IDE / Editor settings
209+
.vscode/
210+
.idea/
211+
212+
# OS files
213+
.DS_Store
214+
215+
# Databricks local config
216+
databricks.yml
210217

211218
# Ruff stuff:
212219
.ruff_cache/

tests/expectations/aggregation/any_value_expectations/test_expect_max_null_count.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
)
1515

1616

17+
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
19+
expectation = DataFrameExpectationRegistry.get_expectation(
20+
expectation_name="ExpectationMaxNullCount",
21+
column_name="col1",
22+
max_count=5,
23+
)
24+
assert expectation.get_expectation_name() == "ExpectationMaxNullCount", (
25+
f"Expected 'ExpectationMaxNullCount' but got: {expectation.get_expectation_name()}"
26+
)
27+
28+
1729
@pytest.mark.parametrize(
1830
"df_data, column_name, max_count, expected_result, expected_message",
1931
[

tests/expectations/aggregation/any_value_expectations/test_expect_max_null_percentage.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414
)
1515

1616

17+
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
19+
expectation = DataFrameExpectationRegistry.get_expectation(
20+
expectation_name="ExpectationMaxNullPercentage",
21+
column_name="col1",
22+
max_percentage=10.0,
23+
)
24+
assert expectation.get_expectation_name() == "ExpectationMaxNullPercentage", (
25+
f"Expected 'ExpectationMaxNullPercentage' but got: {expectation.get_expectation_name()}"
26+
)
27+
28+
1729
@pytest.mark.parametrize(
1830
"df_data, column_name, max_percentage, expected_result, expected_message",
1931
[

tests/expectations/aggregation/any_value_expectations/test_expect_max_rows.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
)
1515

1616

17+
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
19+
expectation = DataFrameExpectationRegistry.get_expectation(
20+
expectation_name="ExpectationMaxRows",
21+
max_rows=10,
22+
)
23+
assert expectation.get_expectation_name() == "ExpectationMaxRows", (
24+
f"Expected 'ExpectationMaxRows' but got: {expectation.get_expectation_name()}"
25+
)
26+
27+
1728
@pytest.mark.parametrize(
1829
"df_data, max_rows, expected_result, expected_message",
1930
[

tests/expectations/aggregation/any_value_expectations/test_expect_min_rows.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@
1414
)
1515

1616

17+
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
19+
expectation = DataFrameExpectationRegistry.get_expectation(
20+
expectation_name="ExpectationMinRows",
21+
min_rows=10,
22+
)
23+
assert expectation.get_expectation_name() == "ExpectationMinRows", (
24+
f"Expected 'ExpectationMinRows' but got: {expectation.get_expectation_name()}"
25+
)
26+
27+
1728
@pytest.mark.parametrize(
1829
"df_data, min_rows, expected_result, expected_message",
1930
[

tests/expectations/aggregation/any_value_expectations/test_expect_unique_rows.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,3 +218,21 @@ def test_column_missing_error(dataframe_factory):
218218
)
219219
with pytest.raises(DataFrameExpectationsSuiteFailure):
220220
expectations_suite.build().run(data_frame=data_frame)
221+
222+
223+
def test_large_dataset_performance(dataframe_factory):
224+
"""
225+
Test the expectation with a larger dataset to ensure reasonable performance.
226+
"""
227+
df_lib, make_df = dataframe_factory
228+
229+
expectation = DataFrameExpectationRegistry.get_expectation(
230+
expectation_name="ExpectationUniqueRows",
231+
column_names=["col1"],
232+
)
233+
# Create a DataFrame with unique values
234+
data_frame = make_df({"col1": (list(range(10000)), "long")})
235+
result = expectation.validate(data_frame=data_frame)
236+
assert isinstance(result, DataFrameExpectationSuccessMessage), (
237+
f"Expected DataFrameExpectationSuccessMessage but got: {type(result)}"
238+
)

tests/expectations/column/string_expectations/test_expect_string_not_contains.py

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
1819
expectation = DataFrameExpectationRegistry.get_expectation(
1920
expectation_name="ExpectationStringNotContains",
2021
column_name="col1",
@@ -35,21 +36,21 @@ def test_expectation_name():
3536
# Success different substring
3637
(["hello", "world", "python"], "java", "success", None),
3738
# Basic violations
38-
(["foobar", "bar", "foo"], "foo", "violations", ["foobar", "foo"]),
39+
(["foobar", "bar", "foo"], "foo", "failure", ["foobar", "foo"]),
3940
# All violations
4041
(
4142
["testing", "test", "attest"],
4243
"test",
43-
"violations",
44+
"failure",
4445
["testing", "test", "attest"],
4546
),
4647
# Mixed violations
47-
(["good", "bad", "badge"], "bad", "violations", ["bad", "badge"]),
48+
(["good", "bad", "badge"], "bad", "failure", ["bad", "badge"]),
4849
# Substring at beginning
4950
(
5051
["prefix_test", "prefix_demo", "other"],
5152
"prefix",
52-
"violations",
53+
"failure",
5354
["prefix_test", "prefix_demo"],
5455
),
5556
# No substring at beginning
@@ -58,7 +59,7 @@ def test_expectation_name():
5859
(
5960
["test_suffix", "demo_suffix", "other"],
6061
"suffix",
61-
"violations",
62+
"failure",
6263
["test_suffix", "demo_suffix"],
6364
),
6465
# No substring at end
@@ -67,40 +68,40 @@ def test_expectation_name():
6768
(
6869
["pre_mid_post", "another_mid_test", "nomatch"],
6970
"mid",
70-
"violations",
71+
"failure",
7172
["pre_mid_post", "another_mid_test"],
7273
),
7374
# No substring in middle
7475
(["no_match", "also_no", "nope"], "mid", "success", None),
7576
# Case sensitive success
7677
(["FOO", "Foo", "fOo"], "foo", "success", None),
7778
# Case sensitive violations
78-
(["foo", "FOO", "test"], "FOO", "violations", ["FOO"]),
79+
(["foo", "FOO", "test"], "FOO", "failure", ["FOO"]),
7980
# Empty string success
8081
(["", "", ""], "foo", "success", None),
8182
# Empty string with violation
82-
(["", "foo", ""], "foo", "violations", ["foo"]),
83+
(["", "foo", ""], "foo", "failure", ["foo"]),
8384
# Whitespace only success
8485
([" ", " ", " "], "test", "success", None),
8586
# Whitespace in text violations
8687
(
8788
["test with spaces", "test", "no match"],
8889
"test",
89-
"violations",
90+
"failure",
9091
["test with spaces", "test"],
9192
),
9293
# Whitespace around violations
9394
(
9495
[" test ", "test", "clean"],
9596
"test",
96-
"violations",
97+
"failure",
9798
[" test ", "test"],
9899
),
99100
# Special char at violations
100101
(
101102
["test@email", "user@domain", "plain"],
102103
"@",
103-
"violations",
104+
"failure",
104105
["test@email", "user@domain"],
105106
),
106107
# Special char at success
@@ -109,35 +110,35 @@ def test_expectation_name():
109110
(
110111
["test#tag", "demo#hash", "plain"],
111112
"#",
112-
"violations",
113+
"failure",
113114
["test#tag", "demo#hash"],
114115
),
115116
# Numbers violations
116117
(
117118
["version123", "test456", "plain"],
118119
"123",
119-
"violations",
120+
"failure",
120121
["version123"],
121122
),
122123
# Numbers no match
123124
(["v1.0", "v2.1", "v3.5"], "123", "success", None),
124125
# Numbers exact match
125-
(["test", "demo", "123"], "123", "violations", ["123"]),
126+
(["test", "demo", "123"], "123", "failure", ["123"]),
126127
# Single char success
127128
(["a", "b", "c"], "x", "success", None),
128129
# Single char violation
129-
(["a", "b", "c"], "a", "violations", ["a"]),
130+
(["a", "b", "c"], "a", "failure", ["a"]),
130131
# Long string success
131132
(["a" * 100, "b" * 100, "c" * 100], "x", "success", None),
132133
# Long string with substring
133134
(
134135
["a" * 50 + "test" + "b" * 50, "clean" * 20, "other"],
135136
"test",
136-
"violations",
137+
"failure",
137138
["a" * 50 + "test" + "b" * 50],
138139
),
139140
# Exact match
140-
(["test", "demo", "exam"], "test", "violations", ["test"]),
141+
(["test", "demo", "exam"], "test", "failure", ["test"]),
141142
# No exact match
142143
(["test", "demo", "exam"], "testing", "success", None),
143144
],
@@ -208,7 +209,7 @@ def test_expectation_basic_scenarios(
208209
assert suite_result.success, "Expected all expectations to pass"
209210
assert suite_result.total_passed == 1, "Expected 1 passed expectation"
210211
assert suite_result.total_failed == 0, "Expected 0 failed expectations"
211-
else: # violations
212+
else: # failure
212213
violations_df = make_df({"col1": (expected_violations, "string")})
213214
expected_message = (
214215
f"Found {len(expected_violations)} row(s) where 'col1' contains '{substring}'."

tests/expectations/column/string_expectations/test_expect_string_starts_with.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
def test_expectation_name():
18+
"""Test that the expectation name is correctly returned."""
1819
expectation = DataFrameExpectationRegistry.get_expectation(
1920
expectation_name="ExpectationStringStartsWith",
2021
column_name="col1",
@@ -34,7 +35,7 @@ def test_expectation_name():
3435
(
3536
["bar", "baz", "qux"],
3637
"foo",
37-
"violations",
38+
"failure",
3839
["bar", "baz", "qux"],
3940
),
4041
# Exact match success
@@ -43,21 +44,21 @@ def test_expectation_name():
4344
(
4445
["foo", "bar", "baz"],
4546
"foo",
46-
"violations",
47+
"failure",
4748
["bar", "baz"],
4849
),
4950
# Empty strings
5051
(
5152
["", "", ""],
5253
"foo",
53-
"violations",
54+
"failure",
5455
["", "", ""],
5556
),
5657
# Whitespace only violations
5758
(
5859
[" ", " ", " "],
5960
"foo",
60-
"violations",
61+
"failure",
6162
[" ", " ", " "],
6263
),
6364
# Whitespace in text success
@@ -71,21 +72,21 @@ def test_expectation_name():
7172
(
7273
["bar foo", "baz foo", "qux foo"],
7374
"foo",
74-
"violations",
75+
"failure",
7576
["bar foo", "baz foo", "qux foo"],
7677
),
7778
# Special char at violations
7879
(
7980
["@foo", "#foo", "$foo"],
8081
"@",
81-
"violations",
82+
"failure",
8283
["#foo", "$foo"],
8384
),
8485
# Special char in prefix violations
8586
(
8687
["foo@bar", "foo#baz", "foo$qux"],
8788
"foo@",
88-
"violations",
89+
"failure",
8990
["foo#baz", "foo$qux"],
9091
),
9192
# Numbers success
@@ -94,7 +95,7 @@ def test_expectation_name():
9495
(
9596
["1foo", "2foo", "3foo"],
9697
"foo",
97-
"violations",
98+
"failure",
9899
["1foo", "2foo", "3foo"],
99100
),
100101
# Long string success
@@ -108,14 +109,14 @@ def test_expectation_name():
108109
(
109110
["a" * 100, "b" * 100, "c" * 100],
110111
"foo",
111-
"violations",
112+
"failure",
112113
["a" * 100, "b" * 100, "c" * 100],
113114
),
114115
# Mixed violations
115116
(
116117
["foobar", "bar", "foo123"],
117118
"foo",
118-
"violations",
119+
"failure",
119120
["bar"],
120121
),
121122
],
@@ -170,7 +171,7 @@ def test_expectation_basic_scenarios(
170171
assert suite_result.success, "Expected all expectations to pass"
171172
assert suite_result.total_passed == 1, "Expected 1 passed expectation"
172173
assert suite_result.total_failed == 0, "Expected 0 failed expectations"
173-
else: # violations
174+
else: # failure
174175
violations_df = make_df({"col1": (expected_violations, "string")})
175176
expected_message = (
176177
f"Found {len(expected_violations)} row(s) where 'col1' does not start with '{prefix}'."

0 commit comments

Comments
 (0)