aboutsummaryrefslogtreecommitdiff
path: root/tests/test_versions.py
blob: 43a3f33a4d0dea5b49aece32e31bcc41e556e0ca (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# SPDX-License-Identifier: CC0-1.0

# Copyright (C) 2022 Wojtek Kosior <koszko@koszko.org>
#
# Available under the terms of Creative Commons Zero v1.0 Universal.

import pytest

from hydrilla import versions

sample_version_tuples  = [(4, 5, 3), (1, 0, 5), (3,)]
sample_version_strings = ['4.5.3',   '1.0.5',   '3']

sample_versions = [*zip(sample_version_tuples, sample_version_strings)]

@pytest.mark.parametrize('version_tuple', sample_version_tuples)
def test_normalize_version(version_tuple):
    """Verify that normalize_version() produces proper results."""
    assert versions.normalize_version([*version_tuple])    == version_tuple
    assert versions.normalize_version([*version_tuple, 0]) == version_tuple

@pytest.mark.parametrize('version_tuple, string', sample_versions)
def test_parse_version(version_tuple, string):
    """Verify that parse_version() produces proper results."""
    assert versions.parse_version(string)
    assert versions.parse_version(string + '.0') == tuple([*version_tuple, 0])

def test_parse_version_bad_string():
    """Verify that parse_version() raises when passed an invalid string."""
    with pytest.raises(ValueError):
        versions.parse_version('i am not a valid version')

@pytest.mark.parametrize('version_tuple, string', sample_versions)
def test_version_string(version_tuple, string):
    """Verify that version_string() produces proper results."""
    for _version_tuple, _string in [
            (version_tuple,              string),
            (tuple([*version_tuple, 0]), f'{string}.0')
    ]:
        assert versions.version_string(_version_tuple)    == _string
        assert versions.version_string(_version_tuple, 5) == f'{_string}-5'
-avail'>...Mathieu Othacehe 2020-05-29bootloader: grub: Do not run grub-install when creating a disk-image....Mathieu Othacehe 2020-05-29bootloader: Add 'disk-image-installer'....Mathieu Othacehe 2020-05-20bootloader: grub: Allow booting from a Btrfs subvolume....Maxim Cournoyer 2020-05-19gnu: grub: Allow a PNG image and replace "aspect-ratio" with "resolution"....Stefan 2020-05-16bootloader: grub: Refer to the native 'grub-mklayout' and font file....Ludovic Courtès 2020-04-23Merge branch 'master' into core-updates...Marius Bakke 2020-04-20gnu: Add u-boot-pinebook-pro-rk3399....Vagrant Cascadian 2020-04-08Merge branch 'master' into core-updates...Marius Bakke 2020-04-06system: Allow for comma-separated keyboard layouts....Ludovic Courtès 2020-03-29gnu: bootloader: Add grub-minimal-bootloader....Jan Nieuwenhuizen 2020-03-17bootloader: grub: Refactor eye-candy a bit....Maxim Cournoyer 2020-03-17bootloader: grub: Use the all_video module in graphic mode....Maxim Cournoyer 2020-02-02gnu: Add u-boot-cubietruck-bootloader....Julien Lepiller 2020-01-25bootloader: grub: Add gfxmode (resolution) override....Jan Nieuwenhuizen 2020-01-07Revert "bootloader: grub: Add gfxmode (resolution) override."...Tobias Geerinckx-Rice 2020-01-07bootloader: grub: Add gfxmode (resolution) override....Jan Nieuwenhuizen 2020-01-06Adjust module autoloads....Ludovic Courtès 2020-01-03bootloader: Mark "grub.cfg" and "extlinux.conf" as non-substitutable....Ludovic Courtès 2019-12-23bootloader: grub: Add firmware setup entry....Brice Waegeneire 2019-12-14gnu: Add u-boot-pine64-lts-bootloader....Mathieu Othacehe 2019-10-18gnu: Add u-boot-firefly-rk3399....Vagrant Cascadian 2019-10-18gnu: Add u-boot-rock64-rk3328....Vagrant Cascadian 2019-10-18gnu: Add u-boot-rockpro64-rk3399...Caliph Nomble 2019-05-09bootloader: grub: Remove unneeded 'terminal_output'....Ludovic Courtès 2019-04-29gnu: u-boot: Update to 2019.04....Vagrant Cascadian 2019-04-03gnu: Add configuration for depthcharge bootloader....Timothy Sample 2019-03-24bootloader: Add a 'keyboard-layout' field....Ludovic Courtès 2019-03-16bootloader: Use 'invoke/quiet' when running 'grub-install' and co....Ludovic Courtès 2019-03-13Remove traces of "GuixSD"....Ludovic Courtès 2018-11-22gnu: Add u-boot-pinebook....Vagrant Cascadian 2018-11-18bootloader: De-monadify configuration file generators....Ludovic Courtès