Example #1
0
def _field_matches_multiple_values_within_bounds(field, values):
    """
    Return :bool:`True` if the given field _only_ matches against a collection of specified values. This will check
    that the given values match and that no other values within the expected min/max bounds do.
    """
    exact = (field.matches(v) for v in values)
    others_within_bounds = (field.matches(v) for v in compat.range(field.min, field.max) if v not in values)
    return all(exact) and not any(others_within_bounds)
Example #2
0
def _field_matches_single_value_within_bounds(field, value):
    """
    Return :bool:`True` if the given field _only_ matches the given value. This will check that the given
    value matches and that no other values within the expected min/max bounds do.
    """
    exact = field.matches(value)
    others_within_bounds = (field.matches(v) for v in compat.range(field.min, field.max) if v != value)
    return exact is True and not any(others_within_bounds)
Example #3
0
def test_range_wildcard_str_second_field_matches_all_members_within_bounds(second_field_all_match_range_with_step_str):
    """
    Assert that the "second" field created from a "all match" range string with a step value _only_
    matches items within the range itself that are multiples of the step and none other within the bounds.
    """
    start, stop = second_field_all_match_range_with_step_str.min, second_field_all_match_range_with_step_str.max
    step = compat.int(second_field_all_match_range_with_step_str.value.split('/')[-1])
    assert _field_matches_multiple_values_within_bounds(second_field_all_match_range_with_step_str,
                                                        compat.range(start, stop, step))
Example #4
0
def _field_matches_multiple_values_within_bounds(field, values):
    """
    Return :bool:`True` if the given field _only_ matches against a collection of specified values. This will check
    that the given values match and that no other values within the expected min/max bounds do.
    """
    exact = (field.matches(v) for v in values)
    others_within_bounds = (field.matches(v)
                            for v in compat.range(field.min, field.max)
                            if v not in values)
    return all(exact) and not any(others_within_bounds)
Example #5
0
def _field_matches_single_value_within_bounds(field, value):
    """
    Return :bool:`True` if the given field _only_ matches the given value. This will check that the given
    value matches and that no other values within the expected min/max bounds do.
    """
    exact = field.matches(value)
    others_within_bounds = (field.matches(v)
                            for v in compat.range(field.min, field.max)
                            if v != value)
    return exact is True and not any(others_within_bounds)
Example #6
0
def test_range_wildcard_str_second_field_matches_all_members_within_bounds(
        second_field_all_match_range_with_step_str):
    """
    Assert that the "second" field created from a "all match" range string with a step value _only_
    matches items within the range itself that are multiples of the step and none other within the bounds.
    """
    start, stop = second_field_all_match_range_with_step_str.min, second_field_all_match_range_with_step_str.max
    step = compat.int(
        second_field_all_match_range_with_step_str.value.split('/')[-1])
    assert _field_matches_multiple_values_within_bounds(
        second_field_all_match_range_with_step_str,
        compat.range(start, stop, step))
Example #7
0
def second_valid_range_with_step(request):
    """
    Fixture that yields a list of values that represent a range of numbers with a step that are within
    the bounds of the "second" field.
    """
    return compat.range(*request.param)
Example #8
0
def field_partial(request):
    """
    Fixture that yields back partials for creating :class:`~crython.field.CronField` instances.
    """
    return request.param


@pytest.fixture(scope='module')
def default_field(field_partial):
    """
    Fixture that yields back the creation of all partials using the default field value.
    """
    return field_partial(field.DEFAULT_VALUE)


@pytest.fixture(scope='module', params=compat.range(0, 59))
def second_valid_numeral(request):
    """
    Fixture that yields back all valid numerals (inclusive) for the "second" field.
    """
    return request.param


@pytest.fixture(scope='module')
def second_field_valid_numeral(second_valid_numeral):
    """
    Fixture that yields back a :class:`~crython.field.CronField` for the "second" field created
    with a valid numeral.
    """
    return field.second(second_valid_numeral)
Example #9
0
def second_valid_range_with_step(request):
    """
    Fixture that yields a list of values that represent a range of numbers with a step that are within
    the bounds of the "second" field.
    """
    return compat.range(*request.param)
Example #10
0
def field_partial(request):
    """
    Fixture that yields back partials for creating :class:`~crython.field.CronField` instances.
    """
    return request.param


@pytest.fixture(scope='module')
def default_field(field_partial):
    """
    Fixture that yields back the creation of all partials using the default field value.
    """
    return field_partial(field.DEFAULT_VALUE)


@pytest.fixture(scope='module', params=compat.range(0, 59))
def second_valid_numeral(request):
    """
    Fixture that yields back all valid numerals (inclusive) for the "second" field.
    """
    return request.param


@pytest.fixture(scope='module')
def second_field_valid_numeral(second_valid_numeral):
    """
    Fixture that yields back a :class:`~crython.field.CronField` for the "second" field created
    with a valid numeral.
    """
    return field.second(second_valid_numeral)