Skip to content

Commit

Permalink
[MAINTENANCE] Update code to use SuiteFactory pt 1 (#9242)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-stauffer authored and jcampbell committed Jan 24, 2024
1 parent 713416d commit 58b9b65
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 158 deletions.
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

0 comments on commit 58b9b65

Please sign in to comment.