コード例 #1
0
def test_constraints_SEMVER_LT():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_SEMVER_LT)

    assert constraint.apply({'customField': '1.2.1'})
    assert not constraint.apply({'customField': '1.2.2'})
    assert not constraint.apply({'customField': '1.2.3'})
コード例 #2
0
def test_constraints_DATE_BEFORE():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DATE_BEFORE)

    assert not constraint.apply({'currentTime': datetime(2022, 1, 23)})
    assert not constraint.apply({'currentTime': datetime(2022, 1, 22)})
    assert constraint.apply({'currentTime': datetime(2022, 1, 21)})
コード例 #3
0
def test_constraints_NUM_FLOAT():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_NUM_FLOAT)

    assert constraint.apply({'customField': 5})
    assert constraint.apply({'customField': 5.1})
    assert not constraint.apply({'customField': 5.2})
コード例 #4
0
def test_constraints_NUM_LTE():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_NUM_LTE)

    assert constraint.apply({'customField': 4})
    assert constraint.apply({'customField': 5})
    assert not constraint.apply({'customField': 6})
コード例 #5
0
def test_constraint_STR_STARTS_WITH():
    constraint_not_ci = Constraint(constraint_dict=mock_constraints.
                                   CONSTRAINT_DICT_STR_STARTS_WITH_NOT_CI)
    constraint_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_STARTS_WITH_CI)

    assert constraint_ci.apply({'customField': "dogb"})
    assert not constraint_ci.apply({'customField': "parrotb"})
    assert constraint_ci.apply({'customField': "hamsterb"})

    assert constraint_not_ci.apply({'customField': "dogb"})
    assert not constraint_not_ci.apply({'customField': "parrotb"})
    assert not constraint_not_ci.apply({'customField': "hamsterb"})
コード例 #6
0
def test_constraint_STR_ENDS_WITH():
    constraint_not_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_ENDS_WITH_NOT_CI)
    constraint_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_ENDS_WITH_CI)

    assert constraint_ci.apply({'customField': "adog"})
    assert not constraint_ci.apply({'customField': "aparrot"})
    assert constraint_ci.apply({'customField': "ahamster"})

    assert constraint_not_ci.apply({'customField': "adog"})
    assert not constraint_not_ci.apply({'customField': "aparrot"})
    assert not constraint_not_ci.apply({'customField': "ahamster"})
コード例 #7
0
def test_constraint_STR_CONTAINS():
    constraint_not_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_CONTAINS_NOT_CI)
    constraint_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_CONTAINS_CI)

    assert constraint_ci.apply({'customField': "adogb"})
    assert not constraint_ci.apply({'customField': "aparrotb"})
    assert constraint_ci.apply({'customField': "ahamsterb"})

    assert constraint_not_ci.apply({'customField': "adogb"})
    assert not constraint_ci.apply({'customField': "aparrotb"})
    assert not constraint_not_ci.apply({'customField': "ahamsterb"})
コード例 #8
0
def test_constraint_inversion():
    constraint_ci = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DICT_STR_INVERT)

    assert not constraint_ci.apply({'customField': "adogb"})
コード例 #9
0
def test_constraints_semverexception():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_SEMVER_EQ)

    assert not constraint.apply({'customField': 'hamstershamsterhamsters'})
コード例 #10
0
def test_constraints_date_error():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DATE_ERROR)
    assert not constraint.apply({'currentTime': datetime(2022, 1, 23)})
コード例 #11
0
def test_constraints_default():
    constraint = Constraint(
        constraint_dict=mock_constraints.CONSTRAINT_DATE_BEFORE)

    assert not constraint.apply({})