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
|
# test_isvalidatom.py -- Portage Unit Testing Functionality
# Copyright 2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$
from portage.tests import TestCase
from portage.dep import isvalidatom
import portage.dep
portage.dep._dep_check_strict = True
class IsValidAtom(TestCase):
""" A simple testcase for isvalidatom
"""
def testIsValidAtom(self):
tests = [ ( "sys-apps/portage", True ),
( "=sys-apps/portage-2.1", True ),
( "=sys-apps/portage-2.1*", True ),
( ">=sys-apps/portage-2.1", True ),
( "<=sys-apps/portage-2.1", True ),
( ">sys-apps/portage-2.1", True ),
( "<sys-apps/portage-2.1", True ),
( "~sys-apps/portage-2.1", True ),
( "sys-apps/portage:foo", True ),
( "sys-apps/portage-2.1:foo", False ),
( "sys-apps/portage-2.1:", False ),
( "sys-apps/portage-2.1:[foo]", False ),
( "=sys-apps/portage-2.2*:foo[bar?,!baz?,!doc=,build=]", True ),
( "=sys-apps/portage-2.2*:foo[doc?]", True ),
( "=sys-apps/portage-2.2*:foo[!doc?]", True ),
( "=sys-apps/portage-2.2*:foo[doc=]", True ),
( "=sys-apps/portage-2.2*:foo[!doc=]", True ),
( "=sys-apps/portage-2.2*:foo[!doc]", False ),
( "=sys-apps/portage-2.2*:foo[!-doc]", False ),
( "=sys-apps/portage-2.2*:foo[!-doc=]", False ),
( "=sys-apps/portage-2.2*:foo[!-doc?]", False ),
( "=sys-apps/portage-2.2*:foo[-doc?]", False ),
( "=sys-apps/portage-2.2*:foo[-doc=]", False ),
( "=sys-apps/portage-2.2*:foo[-doc!=]", False ),
( "=sys-apps/portage-2.2*:foo[-doc=]", False ),
( "=sys-apps/portage-2.2*:foo[bar][-baz][doc?][!build?]", False ),
( "=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?]", True ),
( "=sys-apps/portage-2.2*:foo[bar,-baz,doc?,!build?,]", False ),
( "=sys-apps/portage-2.2*:foo[,bar,-baz,doc?,!build?]", False ),
( "=sys-apps/portage-2.2*:foo[bar,-baz][doc?,!build?]", False ),
( "=sys-apps/portage-2.2*:foo[bar][doc,build]", False ),
( ">~cate-gory/foo-1.0", False ),
( ">~category/foo-1.0", False ),
( "<~category/foo-1.0", False ),
( "###cat/foo-1.0", False ),
( "~sys-apps/portage", False ),
( "portage", False ),
( "=portage", False ),
( ">=portage-2.1", False ),
( "~portage-2.1", False ),
( "=portage-2.1*", False ),
( "null/portage", True ),
( "=null/portage", False ),
( "=null/portage*", False ),
( "null/portage*:0", False ),
( ">=null/portage-2.1", True ),
( "~null/portage-2.1", True ),
( "=null/portage-2.1*", True ),
# These are invalid because pkg name must not end in hyphen
# followed by numbers
( "=foo/bar-123-1", False ),
( "=foo/bar-123-1-r1", False ),
( "foo/bar-1", False ),
( "=foo/bar--baz-1-r1", True ),
( "=foo/bar-baz--1-r1", True ),
( "=foo/bar-baz---1-r1", True ),
( "=foo/bar-baz---1", True ),
( "=foo/bar-baz-1--r1", False ),
( "games-strategy/ufo2000", True ),
( "~games-strategy/ufo2000-0.1", True ),
( "=media-libs/x264-20060810", True ),
( "foo/b", True ),
( "app-text/7plus", True ),
( "foo/666", True ),
( "=dev-libs/poppler-qt3-0.11*", True ),
]
for test in tests:
if test[1]:
atom_type = "valid"
else:
atom_type = "invalid"
self.assertEqual( bool(isvalidatom( test[0] )), test[1],
msg="isvalidatom(%s) != %s" % ( test[0], test[1] ) )
|