Exemple #1
0
def get_previous_release(current_release):
    """ Return the previously active release from the history file """
    releases = list_releases()

    try:
        current_index = last_index(releases, current_release)
        previous_index = current_index - 1
        if previous_index < 0:
            return None
        else:
            return releases[previous_index]
    except ValueError:
        # raised if the current release is not found
        return None
Exemple #2
0
def test_last_index_empty():
    with pytest.raises(ValueError):
        last_index([], 1)
Exemple #3
0
def test_last_index():
    assert last_index([1, 1], 1) == 1
    assert last_index([1, 1, 2], 1) == 1
Exemple #4
0
def test_last_index_missing():
    with pytest.raises(ValueError):
        last_index([1], 2)