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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
|
# -*- coding: utf-8 -*-
"""
test_description.py
~~~~~~~~~~~~~~~~~~~
test suite for the *g_octave.description* module
:copyright: (c) 2010 by Rafael Goncalves Martins
:license: GPL-2, see LICENSE for more details.
"""
import os
import unittest
import testcase
from g_octave import description
class TestDescription(testcase.TestCase):
def setUp(self):
testcase.TestCase.setUp(self)
self.desc = description.Description(
os.path.join(
os.path.dirname(os.path.abspath(__file__)), 'files', 'pkg-0.0.1.DESCRIPTION',
),
)
def test_re_depends(self):
depends = [
('pkg', ('pkg', None, None)),
('pkg(<1)', ('pkg', '<', '1')),
('pkg(>1)', ('pkg', '>', '1')),
('pkg(<=1)', ('pkg', '<=', '1')),
('pkg(>=1)', ('pkg', '>=', '1')),
('pkg(==1)', ('pkg', '==', '1')),
('pkg( <1)', ('pkg', '<', '1')),
('pkg( >1)', ('pkg', '>', '1')),
('pkg( <=1)', ('pkg', '<=', '1')),
('pkg( >=1)', ('pkg', '>=', '1')),
('pkg( ==1)', ('pkg', '==', '1')),
('pkg(<1 )', ('pkg', '<', '1')),
('pkg(>1 )', ('pkg', '>', '1')),
('pkg(<=1 )', ('pkg', '<=', '1')),
('pkg(>=1 )', ('pkg', '>=', '1')),
('pkg(==1 )', ('pkg', '==', '1')),
('pkg( <1 )', ('pkg', '<', '1')),
('pkg( >1 )', ('pkg', '>', '1')),
('pkg( <=1 )', ('pkg', '<=', '1')),
('pkg( >=1 )', ('pkg', '>=', '1')),
('pkg( ==1 )', ('pkg', '==', '1')),
('pkg(<1.0)', ('pkg', '<', '1.0')),
('pkg(>1.0)', ('pkg', '>', '1.0')),
('pkg(<=1.0)', ('pkg', '<=', '1.0')),
('pkg(>=1.0)', ('pkg', '>=', '1.0')),
('pkg(==1.0)', ('pkg', '==', '1.0')),
('pkg( <1.0)', ('pkg', '<', '1.0')),
('pkg( >1.0)', ('pkg', '>', '1.0')),
('pkg( <=1.0)', ('pkg', '<=', '1.0')),
('pkg( >=1.0)', ('pkg', '>=', '1.0')),
('pkg( ==1.0)', ('pkg', '==', '1.0')),
('pkg(<1.0 )', ('pkg', '<', '1.0')),
('pkg(>1.0 )', ('pkg', '>', '1.0')),
('pkg(<=1.0 )', ('pkg', '<=', '1.0')),
('pkg(>=1.0 )', ('pkg', '>=', '1.0')),
('pkg(==1.0 )', ('pkg', '==', '1.0')),
('pkg( <1.0 )', ('pkg', '<', '1.0')),
('pkg( >1.0 )', ('pkg', '>', '1.0')),
('pkg( <=1.0 )', ('pkg', '<=', '1.0')),
('pkg( >=1.0 )', ('pkg', '>=', '1.0')),
('pkg( ==1.0 )', ('pkg', '==', '1.0')),
('pkg(<1.0.0)', ('pkg', '<', '1.0.0')),
('pkg(>1.0.0)', ('pkg', '>', '1.0.0')),
('pkg(<=1.0.0)', ('pkg', '<=', '1.0.0')),
('pkg(>=1.0.0)', ('pkg', '>=', '1.0.0')),
('pkg(==1.0.0)', ('pkg', '==', '1.0.0')),
('pkg( <1.0.0)', ('pkg', '<', '1.0.0')),
('pkg( >1.0.0)', ('pkg', '>', '1.0.0')),
('pkg( <=1.0.0)', ('pkg', '<=', '1.0.0')),
('pkg( >=1.0.0)', ('pkg', '>=', '1.0.0')),
('pkg( ==1.0.0)', ('pkg', '==', '1.0.0')),
('pkg(<1.0.0 )', ('pkg', '<', '1.0.0')),
('pkg(>1.0.0 )', ('pkg', '>', '1.0.0')),
('pkg(<=1.0.0 )', ('pkg', '<=', '1.0.0')),
('pkg(>=1.0.0 )', ('pkg', '>=', '1.0.0')),
('pkg(==1.0.0 )', ('pkg', '==', '1.0.0')),
('pkg( <1.0.0 )', ('pkg', '<', '1.0.0')),
('pkg( >1.0.0 )', ('pkg', '>', '1.0.0')),
('pkg( <=1.0.0 )', ('pkg', '<=', '1.0.0')),
('pkg( >=1.0.0 )', ('pkg', '>=', '1.0.0')),
('pkg( ==1.0.0 )', ('pkg', '==', '1.0.0')),
('pk-g (<1)', ('pk-g', '<', '1')),
('pk-g (>1)', ('pk-g', '>', '1')),
('pk-g (<=1)', ('pk-g', '<=', '1')),
('pk-g (>=1)', ('pk-g', '>=', '1')),
('pk-g (==1)', ('pk-g', '==', '1')),
('pk-g ( <1)', ('pk-g', '<', '1')),
('pk-g ( >1)', ('pk-g', '>', '1')),
('pk-g ( <=1)', ('pk-g', '<=', '1')),
('pk-g ( >=1)', ('pk-g', '>=', '1')),
('pk-g ( ==1)', ('pk-g', '==', '1')),
('pk-g (<1 )', ('pk-g', '<', '1')),
('pk-g (>1 )', ('pk-g', '>', '1')),
('pk-g (<=1 )', ('pk-g', '<=', '1')),
('pk-g (>=1 )', ('pk-g', '>=', '1')),
('pk-g (==1 )', ('pk-g', '==', '1')),
('pk-g ( <1 )', ('pk-g', '<', '1')),
('pk-g ( >1 )', ('pk-g', '>', '1')),
('pk-g ( <=1 )', ('pk-g', '<=', '1')),
('pk-g ( >=1 )', ('pk-g', '>=', '1')),
('pk-g ( ==1 )', ('pk-g', '==', '1')),
('pk-g (<1.0)', ('pk-g', '<', '1.0')),
('pk-g (>1.0)', ('pk-g', '>', '1.0')),
('pk-g (<=1.0)', ('pk-g', '<=', '1.0')),
('pk-g (>=1.0)', ('pk-g', '>=', '1.0')),
('pk-g ( ==1.0)', ('pk-g', '==', '1.0')),
('pk-g ( <1.0)', ('pk-g', '<', '1.0')),
('pk-g ( >1.0)', ('pk-g', '>', '1.0')),
('pk-g ( <=1.0)', ('pk-g', '<=', '1.0')),
('pk-g ( >=1.0)', ('pk-g', '>=', '1.0')),
('pk-g ( ==1.0)', ('pk-g', '==', '1.0')),
('pk-g (<1.0 )', ('pk-g', '<', '1.0')),
('pk-g (>1.0 )', ('pk-g', '>', '1.0')),
('pk-g (<=1.0 )', ('pk-g', '<=', '1.0')),
('pk-g (>=1.0 )', ('pk-g', '>=', '1.0')),
('pk-g (==1.0 )', ('pk-g', '==', '1.0')),
('pk-g ( <1.0 )', ('pk-g', '<', '1.0')),
('pk-g ( >1.0 )', ('pk-g', '>', '1.0')),
('pk-g ( <=1.0 )', ('pk-g', '<=', '1.0')),
('pk-g ( >=1.0 )', ('pk-g', '>=', '1.0')),
('pk-g ( ==1.0 )', ('pk-g', '==', '1.0')),
('pk-g (<1.0.0)', ('pk-g', '<', '1.0.0')),
('pk-g (>1.0.0)', ('pk-g', '>', '1.0.0')),
('pk-g (<=1.0.0)', ('pk-g', '<=', '1.0.0')),
('pk-g (>=1.0.0)', ('pk-g', '>=', '1.0.0')),
('pk-g (==1.0.0)', ('pk-g', '==', '1.0.0')),
('pk-g ( <1.0.0)', ('pk-g', '<', '1.0.0')),
('pk-g ( >1.0.0)', ('pk-g', '>', '1.0.0')),
('pk-g ( <=1.0.0)', ('pk-g', '<=', '1.0.0')),
('pk-g ( >=1.0.0)', ('pk-g', '>=', '1.0.0')),
('pk-g ( ==1.0.0)', ('pk-g', '==', '1.0.0')),
('pk-g (<1.0.0 )', ('pk-g', '<', '1.0.0')),
('pk-g (>1.0.0 )', ('pk-g', '>', '1.0.0')),
('pk-g (<=1.0.0 )', ('pk-g', '<=', '1.0.0')),
('pk-g (>=1.0.0 )', ('pk-g', '>=', '1.0.0')),
('pk-g (==1.0.0 )', ('pk-g', '==', '1.0.0')),
('pk-g ( <1.0.0 )', ('pk-g', '<', '1.0.0')),
('pk-g ( >1.0.0 )', ('pk-g', '>', '1.0.0')),
('pk-g ( <=1.0.0 )', ('pk-g', '<=', '1.0.0')),
('pk-g ( >=1.0.0 )', ('pk-g', '>=', '1.0.0')),
('pk-g ( ==1.0.0 )', ('pk-g', '==', '1.0.0')),
]
for pkgstr, pkgtpl in depends:
match = description.re_depends.match(pkgstr)
self.assertEqual(
(match.group(1), match.group(3), match.group(4)),
pkgtpl
)
def test_re_pkg_atom(self):
depends = [
('pkg-1.DESCRIPTION', ('pkg-1', 'pkg', '1')),
('pkg-1.0.DESCRIPTION', ('pkg-1.0', 'pkg', '1.0')),
('pkg-1.0.0.DESCRIPTION', ('pkg-1.0.0', 'pkg', '1.0.0')),
]
for pkgstr, pkgtpl in depends:
match = description.re_pkg_atom.match(pkgstr)
self.assertEqual((match.group(1), match.group(2), match.group(3)), pkgtpl)
def test_attributes(self):
# TODO: split this method to improve the error reporting
# TODO: figure out how to test the comments
self.assertEqual(self.desc.name, 'package name')
self.assertEqual(self.desc.version, '0.0.1')
self.assertEqual(self.desc.date, '2009-01-01')
self.assertEqual(self.desc.author, 'Author Name: testing \':\'s in the value.')
self.assertEqual(self.desc.maintainer, 'Maintainer Name')
self.assertEqual(self.desc.title, 'Package Title')
self.assertEqual(self.desc.description, 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.')
self.assertEqual(self.desc.categories, 'Category1,Category2, Category3')
self.assertEqual(self.desc.url, 'http://example.org')
self.assertEqual(self.desc.P, 'pkg-0.0.1')
self.assertEqual(self.desc.PN, 'pkg')
self.assertEqual(self.desc.PV, '0.0.1')
requirements = [
'<g-octave/pkg12-1.2.3',
'g-octave/pkg13',
'>=g-octave/pkg11-4.3.2',
]
self.assertEqual(self.desc.systemrequirements, requirements)
self.assertEqual(self.desc.buildrequires, ['>g-octave/pkg14-1.0.0'])
self.assertEqual(self.desc.depends, ['>=sci-mathematics/octave-3.0.0'])
self.assertEqual(self.desc.autoload, 'NO')
self.assertEqual(self.desc.license, 'GPL version 3 or later')
self.assertEqual(self.desc.sha1sum(), '6d1559b50a09189e5d25b402a004d12cafc8ee4f')
def suite():
suite = unittest.TestSuite()
suite.addTest(TestDescription('test_re_depends'))
suite.addTest(TestDescription('test_re_pkg_atom'))
suite.addTest(TestDescription('test_attributes'))
return suite
|