<gh_stars>0
from tests.helpers.common_test_tables import customers_test_table
from tests.helpers.scanner import Scanner


def test_row_count_thresholds_passing(scanner: Scanner):
    """
    Tests all passing thresholds on a simple row count
    """
    table_name = scanner.ensure_test_table(customers_test_table)

    scan = scanner.create_test_scan()
    scan.add_sodacl_yaml_str(
        f"""
      checks for {table_name}:
        - row_count = 10.0
        - row_count < 11
        - row_count > 9
        - row_count <= 10
        - row_count >= 10
        - row_count != 0
        - row_count <> 0
        - row_count between 10 and 15]
        - row_count between [-5 and 10
        - row_count between (9 and 15]
        - row_count between -5 and 11)
        - row_count not between 11 and 15
        - row_count not between [-5 and 9]
        - row_count not between (10 and 15
        - row_count not between -5 and 10)
    """
    )
    scan.execute()

    scan.assert_all_checks_pass()


def test_row_count_thresholds_failing(scanner: Scanner):
    """
    Tests all failing thresholds on a simple row count
    """
    table_name = scanner.ensure_test_table(customers_test_table)

    # Row count is 10
    scan = scanner.create_test_scan()
    scan.add_sodacl_yaml_str(
        f"""
      checks for {table_name}:
        - row_count < 10
        - row_count > 10
        - row_count <= 9
        - row_count >= 11
        - row_count between 11 and 15
        - row_count between 5 and 9]
        - row_count between (10 and 15
        - row_count between 5 and 10)
        - row_count not between [10 and 15
        - row_count not between [5 and 10]
        - row_count not between (9 and 15]
        - row_count not between [5 and 11)
    """
    )
    scan.execute()

    scan.assert_all_checks_fail()

from tests.helpers.common_test_tables import customers_test_table
from tests.helpers.scanner import Scanner


def test_row_count_thresholds_passing(scanner: Scanner):
    """
    Tests all passing thresholds on a simple row count
    """
    table_name = scanner.ensure_test_table(customers_test_table)

    scan = scanner.create_test_scan()
    scan.add_sodacl_yaml_str(
        f"""
      checks for {table_name}:
        - row_count = 10.0
        - row_count < 11
        - row_count > 9
        - row_count <= 10
        - row_count >= 10
        - row_count != 0
        - row_count <> 0
        - row_count between 10 and 15]
        - row_count between [-5 and 10
        - row_count between (9 and 15]
        - row_count between -5 and 11)
        - row_count not between 11 and 15
        - row_count not between [-5 and 9]
        - row_count not between (10 and 15
        - row_count not between -5 and 10)
    """
    )
    scan.execute()

    scan.assert_all_checks_pass()


def test_row_count_thresholds_failing(scanner: Scanner):
    """
    Tests all failing thresholds on a simple row count
    """
    table_name = scanner.ensure_test_table(customers_test_table)

    # Row count is 10
    scan = scanner.create_test_scan()
    scan.add_sodacl_yaml_str(
        f"""
      checks for {table_name}:
        - row_count < 10
        - row_count > 10
        - row_count <= 9
        - row_count >= 11
        - row_count between 11 and 15
        - row_count between 5 and 9]
        - row_count between (10 and 15
        - row_count between 5 and 10)
        - row_count not between [10 and 15
        - row_count not between [5 and 10]
        - row_count not between (9 and 15]
        - row_count not between [5 and 11)
    """
    )
    scan.execute()

    scan.assert_all_checks_fail()
Tests all passing thresholds on a simple row count checks for {table_name}:         - row_count = 10.0         - row_count < 11         - row_count > 9         - row_count <= 10         - row_count >= 10         - row_count != 0         - row_count <> 0         - row_count between 10 and 15]         - row_count between [-5 and 10         - row_count between (9 and 15]         - row_count between -5 and 11)         - row_count not between 11 and 15         - row_count not between [-5 and 9]         - row_count not between (10 and 15         - row_count not between -5 and 10) Tests all failing thresholds on a simple row count # Row count is 10 checks for {table_name}:         - row_count < 10         - row_count > 10         - row_count <= 9         - row_count >= 11         - row_count between 11 and 15         - row_count between 5 and 9]         - row_count between (10 and 15         - row_count between 5 and 10)         - row_count not between [10 and 15         - row_count not between [5 and 10]         - row_count not between (9 and 15]         - row_count not between [5 and 11)