File: pkg_openbsd.py

package info (click to toggle)
bundlewrap 4.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,216 kB
  • sloc: python: 20,299; makefile: 2
file content (95 lines) | stat: -rw-r--r-- 2,558 bytes parent folder | download | duplicates (4)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from bundlewrap.items.pkg_openbsd import parse_pkg_name

from pytest import raises


def test_not_found():
    found, version, flavor = parse_pkg_name("rsync", "irssi-1.0.4p0-socks")
    assert found is False


def test_only_version():
    found, version, flavor = parse_pkg_name("irssi", "irssi-1.0.4p0")
    assert found is True
    assert version == "1.0.4p0"
    assert flavor == ""


def test_version_and_flavor():
    found, version, flavor = parse_pkg_name("irssi", "irssi-1.0.4p0-socks")
    assert found is True
    assert version == "1.0.4p0"
    assert flavor == "socks"


def test_dashname_not_found():
    found, version, flavor = parse_pkg_name("rsync", "cyrus-sasl-2.1.26p24-pgsql")
    assert found is False


def test_dashname_only_version():
    found, version, flavor = parse_pkg_name("cyrus-sasl", "cyrus-sasl-2.1.26p24")
    assert found is True
    assert version == "2.1.26p24"
    assert flavor == ""


def test_dashname_version_and_flavor():
    found, version, flavor = parse_pkg_name("cyrus-sasl", "cyrus-sasl-2.1.26p24-pgsql")
    assert found is True
    assert version == "2.1.26p24"
    assert flavor == "pgsql"


def test_dashflavor_not_found():
    found, version, flavor = parse_pkg_name("rsync", "vim-8.0.0987p0-gtk2-lua")
    assert found is False


def test_dashflavor_version_and_flavor():
    found, version, flavor = parse_pkg_name("vim", "vim-8.0.0987p0-gtk2-lua")
    assert found is True
    assert version == "8.0.0987p0"
    assert flavor == "gtk2-lua"


def test_dashall_not_found():
    found, version, flavor = parse_pkg_name("rsync", "graphical-vim-8.0.0987p0-gtk2-lua")
    assert found is False


def test_dashall_not_found_dash_in_pkgname():
    found, version, flavor = parse_pkg_name("graphical-vim", "graphical-vim-8.0.0987p0-gtk2-lua")
    assert found is True
    assert version == "8.0.0987p0"
    assert flavor == "gtk2-lua"


def test_illegal_version_ends_with_dash():
    with raises(AssertionError):
        parse_pkg_name("dummy", "foo-1.0-")


def test_illegal_flavor_ends_with_dash():
    with raises(AssertionError):
        parse_pkg_name("dummy", "foo-1.0-bar-")


def test_illegal_no_version():
    with raises(AssertionError):
        parse_pkg_name("dummy", "foo-bar")


def test_illegal_no_name():
    with raises(AssertionError):
        parse_pkg_name("dummy", "1.0-flavor")


def test_illegal_only_version():
    with raises(AssertionError):
        parse_pkg_name("dummy", "1.0")


def test_illegal_empty_line():
    with raises(AssertionError):
        parse_pkg_name("dummy", "")