File: test_requirement_specs.py

package info (click to toggle)
scap-security-guide 0.1.78-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 114,600 kB
  • sloc: xml: 245,305; sh: 84,381; python: 33,093; makefile: 27
file content (35 lines) | stat: -rw-r--r-- 1,307 bytes parent folder | download | duplicates (2)
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
import pytest

from ssg import requirement_specs


def test_parse_version_into_evr():
    v = requirement_specs._parse_version_into_evr('1.22.333-4444')
    assert v == {'epoch': None, 'version': '1.22.333', 'release': '4444'}

    v = requirement_specs._parse_version_into_evr('0')
    assert v == {'epoch': None, 'version': '0', 'release': None}

    v = requirement_specs._parse_version_into_evr('0-1')
    assert v == {'epoch': None, 'version': '0', 'release': '1'}

    # Empty version is not the same as version '0'.
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('')

    # we do not support letters anywhere for now

    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('1.0.0-r2')
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('b1')

    # some more tests to ensure that the regex is correct
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('0:')
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('-1')
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr(':')
    with pytest.raises(ValueError):
        v = requirement_specs._parse_version_into_evr('-')