]> git.decadent.org.uk Git - dak.git/blob - test/005/test.py
3f6ca258393aa5f07bf3192ec6b3683da7c2ff50
[dak.git] / test / 005 / test.py
1 #!/usr/bin/env python
2
3 # Check utils.parse_changes()'s for handling of multi-line fields
4 # Copyright (C) 2004  James Troup <james@nocrew.org>
5 # $Id: test.py,v 1.1 2004-01-21 03:20:52 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 # Check util.parse_changes() correctly ignores data outside the signed area
24
25 ################################################################################
26
27 import os, sys
28
29 sys.path.append(os.path.abspath('../../'));
30
31 import utils
32
33 ################################################################################
34
35 def fail(message):
36     sys.stderr.write("%s\n" % (message));
37     sys.exit(1);
38
39 ################################################################################
40
41 def main ():
42     for file in [ "valid", "bogus-pre", "bogus-post", "evil" ]:
43         for strict_whitespace in [ 0, 1 ]:
44             if file == "evil" and strict_whitespace == 1:
45                 continue;
46             try:
47                 changes = utils.parse_changes("%s.changes" % (file), strict_whitespace)
48             except utils.changes_parse_error_exc, line:
49                 fail("%s[%s]: parse_changes() returned an exception with error message `%s'." % (file, strict_whitespace, line));
50             oh_dear = changes.get("you");
51             if oh_dear:
52                 fail("%s[%s]: parsed and accepted unsigned data!" % (file, strict_whitespace));
53
54 ################################################################################
55
56 if __name__ == '__main__':
57     main()