3 # Check utils.extract_component_from_section()
4 # Copyright (C) 2000, 2006 James Troup <james@nocrew.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 ################################################################################
24 sys.path.append(os.path.abspath('../../'))
28 ################################################################################
31 sys.stderr.write("%s\n" % (message))
34 ################################################################################
37 # component: main, contrib, non-free
38 # section: games, admin, libs, [...]
40 # [1] Order is as above.
41 # [2] Prefix is optional for the default archive, but mandatory when
42 # uploads are going anywhere else.
43 # [3] Default component is main and may be omitted.
44 # [4] Section is optional.
45 # [5] Prefix is case insensitive
46 # [6] Everything else is case sensitive.
48 def test(input, output):
49 result = utils.extract_component_from_section(input)
51 fail ("%s -> %r [should have been %r]" % (input, result, output))
54 # Err, whoops? should probably be "utils", "main"...
55 input = "main/utils"; output = ("main/utils", "main")
60 input = "utils"; output = ("utils", "main")
63 input = "non-free/libs"; output = ("non-free/libs", "non-free")
66 input = "contrib/net"; output = ("contrib/net", "contrib")
70 # Validate #3 with a prefix
71 input = "non-US"; output = ("non-US", "non-US/main")
76 input = "main"; output = ("main", "main")
79 input = "contrib"; output = ("contrib", "contrib")
82 input = "non-free"; output = ("non-free", "non-free")
86 # Validate #4 with a prefix
87 input = "non-US/main"; output = ("non-US/main", "non-US/main")
90 input = "non-US/contrib"; output = ("non-US/contrib", "non-US/contrib")
93 input = "non-US/non-free"; output = ("non-US/non-free", "non-US/non-free")
98 input = "non-us"; output = ("non-us", "non-US/main")
101 input = "non-us/contrib"; output = ("non-us/contrib", "non-US/contrib")
105 # Validate #6 (section)
106 input = "utIls"; output = ("utIls", "main")
110 input = "non-US/libs"; output = ("non-US/libs", "non-US/main")
112 input = "non-US/main/libs"; output = ("non-US/main/libs", "non-US/main")
114 input = "non-US/contrib/libs"; output = ("non-US/contrib/libs", "non-US/contrib")
116 input = "non-US/non-free/libs"; output = ("non-US/non-free/libs", "non-US/non-free")
119 ################################################################################
121 if __name__ == '__main__':