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
|
#!/usr/bin/python -tt
# vim: fileencoding=utf8 foldmethod=marker
# {{{ License header: GPLv2+
# This file is part of cnucnu.
#
# Cnucnu is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# Cnucnu is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cnucnu. If not, see <http://www.gnu.org/licenses/>.
# }}}
import unittest
import sys
sys.path.insert(0, '../..')
from cnucnu import unalias, ALIASES
class AliasTest(unittest.TestCase):
def testDefaultRegex(self):
regex = unalias("testname", "DEFAULT", "regex")
self.assertEqual(regex, ALIASES["DEFAULT"]["regex"].format(
name="testname"))
def testOverride(self):
regex = unalias("testname", "TEST:", "regex")
self.assertEqual(regex, "TEST:")
def testCPAN(self):
url = unalias("perl-test", "CPAN-DEFAULT", "url")
self.assertEqual(url, "http://search.cpan.org/dist/test/")
url = unalias("perl-test", "CPAN-DEFAULT:overridden-name", "url")
self.assertEqual(url, "http://search.cpan.org/dist/overridden-name/")
def testDebian(self):
url = unalias("testpackage", "DEBIAN-DEFAULT", "url")
self.assertEqual(
url,
"http://ftp.debian.org/debian/pool/main/t/testpackage/"
)
def testDrupalRegex(self):
regex = unalias("drupal6-testpackage", "DRUPAL-DEFAULT", "regex")
self.assertEqual(
regex,
"(?s)Recommended releases.*?>6.x-([^<]*)"
)
regex = unalias("drupal7-testpackage", "DRUPAL-DEFAULT", "regex")
self.assertEqual(
regex,
"(?s)Recommended releases.*?>7.x-([^<]*)"
)
def testDrupalUrl(self):
url = unalias("drupal6-testpkg", "DRUPAL-DEFAULT", "url")
self.assertEqual(
url,
"http://drupal.org/project/testpkg"
)
def testPHPPear(self):
url = unalias("php-pear-Test-Case", "PEAR-DEFAULT", "url")
self.assertEqual(
url,
"http://pear.php.net/package/Test_Case/download/All"
)
if __name__ == "__main__":
suite = unittest.TestLoader().loadTestsFromTestCase(AliasTest)
unittest.TextTestRunner(verbosity=2).run(suite)
#unittest.main()
|