]> git.decadent.org.uk Git - dak.git/blob - dak/test/003/test.py
Stop using silly names, and migrate to a saner directory structure.
[dak.git] / dak / test / 003 / test.py
1 #!/usr/bin/env python
2
3 # Check utils.parse_changes()'s for handling of multi-line fields
4 # Copyright (C) 2000  James Troup <james@nocrew.org>
5 # $Id: test.py,v 1.2 2002-10-16 02:47:32 troup Exp $
6
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.
11
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.
16
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
20
21 ################################################################################
22
23 # The deal here is that for the first 6 months of katie's
24 # implementation it has been misparsing multi-line fields in .changes
25 # files; specifically multi-line fields where there _is_ data on the
26 # first line. So, for example:
27
28 # Foo: bar baz
29 #  bat bant
30
31 # Became "foo: bar bazbat bant" rather than "foo: bar baz\nbat bant"
32
33 ################################################################################
34
35 import os, sys
36
37 sys.path.append(os.path.abspath('../../'));
38
39 import utils
40
41 ################################################################################
42
43 def fail(message):
44     sys.stderr.write("%s\n" % (message));
45     sys.exit(1);
46
47 ################################################################################
48
49 def main ():
50     # Valid .changes file with a multi-line Binary: field
51     try:
52         changes = utils.parse_changes('krb5_1.2.2-4_m68k.changes', 0)
53     except utils.changes_parse_error_exc, line:
54         fail("parse_changes() returned an exception with error message `%s'." % (line));
55
56     o = changes.get("binary", "")
57     if o != "":
58         del changes["binary"]
59     changes["binary"] = {}
60     for j in o.split():
61         changes["binary"][j] = 1
62
63     if not changes["binary"].has_key("krb5-ftpd"):
64         fail("parse_changes() is broken; 'krb5-ftpd' is not in the Binary: dictionary.");
65
66 ################################################################################
67
68 if __name__ == '__main__':
69     main()