Ejemplo n.º 1
0
def version_mmpb():
    v = ver.Version()
    v.create_part('major', 4)
    v.create_part('minor', 3)
    v.create_part('patch', 1)
    v.create_part('build', 5, start_value=1)
    return v
Ejemplo n.º 2
0
def test_version_add_parts():
    v = ver.Version()
    part_major = vp.IntegerVersionPart('major', 4)
    part_minor = vp.IntegerVersionPart('minor', 3)
    v.add_part(part_major)
    v.add_part(part_minor)

    assert v.get_part('major').value == 4
    assert v.get_part('minor').value == 3
    assert v.keys == ['major', 'minor']
Ejemplo n.º 3
0
def test_process_version():
    v = version.Version()
    v.create_part('major', 4)
    v.create_part('minor', 3)
    v.create_part('patch', 1)

    action_dict = {'minor': '4'}

    action = set_part.SetPartAction(action_dict)

    new_version = action.process_version(v)

    assert new_version.get_part('major').value == 4
    assert new_version.get_part('minor').value == 4
    assert new_version.get_part('patch').value == 1
Ejemplo n.º 4
0
def test_process_version():
    v = version.Version()
    v.create_part('major', 4)
    v.create_part('minor', 3)
    v.create_part('patch', 1)

    action_dict = {'part': 'major'}

    action = increase_part.IncreasePartAction(action_dict)

    new_version = action.process_version(v)

    assert new_version.get_part('major').value == 5
    assert new_version.get_part('minor').value == 0
    assert new_version.get_part('patch').value == 0
Ejemplo n.º 5
0
def test_conditional_reset_process_version_calls_increment_on_field(mocker):
    mocker.patch('punch.version_part.IntegerVersionPart.inc')
    strftime = mocker.patch('punch.version_part.strftime')
    strftime.return_value = 2016
    v = ver.Version()
    part_year = vp.DateVersionPart('year', 2016, '%Y')
    part_build = vp.IntegerVersionPart('build')
    v.add_part(part_year)
    v.add_part(part_build)

    a = action.ConditionalResetAction(field='build', update_fields=['year'])

    a.process_version(v)

    assert part_build.inc.called
Ejemplo n.º 6
0
def test_conditional_reset_process_version_calls_reset_on_field(mocker):
    mocker.patch('punch.version_part.IntegerVersionPart.reset')
    v = ver.Version()
    part_year = vp.DateVersionPart('year', 2016, '%Y')
    part_month = vp.DateVersionPart('month', 1, '%m')
    part_build = vp.IntegerVersionPart('build')
    v.add_part(part_year)
    v.add_part(part_month)
    v.add_part(part_build)

    a = action.ConditionalResetAction(field='build',
                                      update_fields=['year', 'month'])

    a.process_version(v)

    assert part_build.reset.called
Ejemplo n.º 7
0
def test_conditional_reset_process_version_checks_all_update_fields(mocker):
    mocker.patch('punch.version_part.DateVersionPart.inc')
    v = ver.Version()
    part_year = vp.DateVersionPart('year', 2016, '%Y')
    part_month = vp.DateVersionPart('month', 1, '%m')
    part_build = vp.IntegerVersionPart('build')
    v.add_part(part_year)
    v.add_part(part_month)
    v.add_part(part_build)

    a = conditional_reset.ConditionalResetAction({
        'field': 'build',
        'update_fields': ['year', 'month']
    })

    a.process_version(v)

    assert part_year.inc.called
    assert part_month.inc.called
Ejemplo n.º 8
0
def test_version_may_specify_part_class():
    v = ver.Version()
    v.create_part('major', 4, vp.ValueListVersionPart, [0, 2, 4, 6, 8])
    assert isinstance(v.get_part('major'), vp.ValueListVersionPart)
    assert v.get_part('major').value == 4
    assert v.get_part('major').values == [0, 2, 4, 6, 8]
Ejemplo n.º 9
0
def test_version_default_part_is_integer():
    v = ver.Version()
    v.create_part('major', 4)
    assert isinstance(v.get_part('major'), vp.IntegerVersionPart)
Ejemplo n.º 10
0
def version_mmp():
    v = ver.Version()
    v.create_part('major', 4)
    v.create_part('minor', 3)
    v.create_part('patch', 1)
    return v
Ejemplo n.º 11
0
def version_mm():
    v = ver.Version()
    v.create_part('major', '2018', vpart.DateVersionPart, '%Y')
    v.create_part('minor', '04', vpart.DateVersionPart, '%m')
    return v