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

[MAINTENANCE] Update code to use SuiteFactory pt 1 #9242

Merged
merged 11 commits into from
Jan 18, 2024
41 changes: 18 additions & 23 deletions tests/checkpoint/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@
import pytest

import great_expectations.expectations as gxe
from great_expectations.core import ExpectationSuite
from great_expectations.core.yaml_handler import YAMLHandler
from great_expectations.data_context import get_context
from great_expectations.data_context.data_context.file_data_context import (
FileDataContext,
)
from great_expectations.data_context.util import file_relative_path
from great_expectations.datasource.fluent import BatchRequest as FluentBatchRequest
from great_expectations.expectations.expectation_configuration import (
ExpectationConfiguration,
)


@pytest.fixture
Expand Down Expand Up @@ -99,14 +97,13 @@ def titanic_pandas_data_context_stats_enabled_and_expectation_suite_with_one_exp
):
context = titanic_pandas_data_context_with_v013_datasource_with_checkpoints_v1_with_empty_store_stats_enabled
# create expectation suite
suite = context.add_expectation_suite("my_expectation_suite")
suite = context.suites.add(ExpectationSuite("my_expectation_suite"))
expectation = gxe.ExpectColumnValuesToBeBetween(
column="col1",
min_value=1,
max_value=2,
)
suite.add_expectation(expectation=expectation)
context.update_expectation_suite(expectation_suite=suite)
# noinspection PyProtectedMember
context._save_project_config()
return context
Expand Down Expand Up @@ -137,13 +134,13 @@ def titanic_data_context_with_fluent_pandas_datasources_stats_enabled_and_expect
_ = asset.build_batch_request(dataframe=test_df)

# create expectation suite
suite = context.add_expectation_suite("my_expectation_suite")
expectation = ExpectationConfiguration(
expectation_type="expect_column_values_to_be_between",
kwargs={"column": "col1", "min_value": 1, "max_value": 2},
suite = context.suites.add(ExpectationSuite("my_expectation_suite"))
expectation = gxe.ExpectColumnValuesToBeBetween(
column="col1",
min_value=1,
max_value=2,
)
suite.add_expectation_configuration(expectation, send_usage_event=False)
context.update_expectation_suite(expectation_suite=suite)
suite.add_expectation(expectation)
# noinspection PyProtectedMember
context._save_project_config()

Expand All @@ -168,13 +165,13 @@ def titanic_data_context_with_fluent_pandas_and_spark_datasources_stats_enabled_
)

# create expectation suite
suite = context.add_expectation_suite("my_expectation_suite")
expectation = ExpectationConfiguration(
expectation_type="expect_column_values_to_be_between",
kwargs={"column": "col1", "min_value": 1, "max_value": 2},
suite = context.suites.add(ExpectationSuite("my_expectation_suite"))
expectation = gxe.ExpectColumnValuesToBeBetween(
column="col1",
min_value=1,
max_value=2,
)
suite.add_expectation_configuration(expectation, send_usage_event=False)
context.update_expectation_suite(expectation_suite=suite)
suite.add_expectation(expectation)
# noinspection PyProtectedMember
context._save_project_config()

Expand Down Expand Up @@ -400,13 +397,11 @@ def context_with_single_csv_spark_and_suite(
):
context = context_with_single_taxi_csv_spark
# create expectation suite
suite = context.add_expectation_suite("my_expectation_suite")
expectation = ExpectationConfiguration(
expectation_type="expect_column_to_exist",
kwargs={"column": "pickup_datetime"},
suite = context.suites.add(ExpectationSuite("my_expectation_suite"))
expectation = gxe.ExpectColumnToExist(
column="pickup_datetime",
)
suite.add_expectation_configuration(expectation, send_usage_event=False)
context.update_expectation_suite(expectation_suite=suite)
suite.add_expectation(expectation)
# noinspection PyProtectedMember
context._save_project_config()
return context