3 # Check utils.extract_component_from_section()
4 # Copyright (C) 2000 James Troup <james@nocrew.org>
5 # $Id: test.py,v 1.3 2002-10-16 02:47:32 troup Exp $
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 ################################################################################
25 sys.path.append(os.path.abspath('../../'));
29 ################################################################################
32 sys.stderr.write("%s\n" % (message));
35 ################################################################################
38 # component: main, contrib, non-free
39 # section: games, admin, libs, [...]
41 # [1] Order is as above.
42 # [2] Prefix is optional for the default archive, but mandatory when
43 # uploads are going anywhere else.
44 # [3] Default component is main and may be omitted.
45 # [4] Section is optional.
46 # [5] Prefix is case insensitive
47 # [6] Everything else is case sensitive.
49 def test(input, output):
50 result = utils.extract_component_from_section(input);
52 fail ("%s -> %r [should have been %r]" % (input, result, output));
55 # Err, whoops? should probably be "utils", "main"...
56 input = "main/utils"; output = ("main/utils", "main");
61 input = "utils"; output = ("utils", "main");
64 input = "non-free/libs"; output = ("non-free/libs", "non-free");
67 input = "contrib/net"; output = ("contrib/net", "contrib");
71 # Validate #3 with a prefix
72 input = "non-US"; output = ("non-US", "non-US/main");
77 input = "main"; output = ("main", "main");
80 input = "contrib"; output = ("contrib", "contrib");
83 input = "non-free"; output = ("non-free", "non-free");
87 # Validate #4 with a prefix
88 input = "non-US/main"; output = ("non-US/main", "non-US/main");
91 input = "non-US/contrib"; output = ("non-US/contrib", "non-US/contrib");
94 input = "non-US/non-free"; output = ("non-US/non-free", "non-US/non-free");
99 input = "non-us"; output = ("non-us", "non-US/main");
100 test (input, output);
102 input = "non-us/contrib"; output = ("non-us/contrib", "non-US/contrib");
103 test (input, output);
106 # Validate #6 (section)
107 input = "utIls"; output = ("utIls", "main");
108 test (input, output);
111 input = "non-US/libs"; output = ("non-US/libs", "non-US/main");
112 test (input, output);
113 input = "non-US/main/libs"; output = ("non-US/main/libs", "non-US/main");
114 test (input, output);
115 input = "non-US/contrib/libs"; output = ("non-US/contrib/libs", "non-US/contrib");
116 test (input, output);
117 input = "non-US/non-free/libs"; output = ("non-US/non-free/libs", "non-US/non-free");
118 test (input, output);
120 ################################################################################
122 if __name__ == '__main__':