]> git.decadent.org.uk Git - dak.git/blob - dak/test/001/test.py
Stop using silly names, and migrate to a saner directory structure.
[dak.git] / dak / test / 001 / test.py
1 #!/usr/bin/env python
2
3 # Check utils.parse_changes()'s .dsc file validation
4 # Copyright (C) 2000  James Troup <james@nocrew.org>
5 # $Id: test.py,v 1.1 2001-01-28 09:06:44 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 import os, sys
24
25 sys.path.append(os.path.abspath('../../'));
26
27 import utils
28
29 ################################################################################
30
31 def fail(message):
32     sys.stderr.write("%s\n" % (message));
33     sys.exit(1);
34     
35 ################################################################################
36
37 def main ():
38     # Valid .dsc
39     utils.parse_changes('1.dsc',1);
40
41     # Missing blank line before signature body
42     try:
43         utils.parse_changes('2.dsc',1);
44     except utils.invalid_dsc_format_exc, line:
45         if line != 14:
46             fail("Incorrect line number ('%s') for test #2." % (line));
47     else:
48         fail("Test #2 wasn't recognised as invalid.");
49
50     # Missing blank line after signature header
51     try:
52         utils.parse_changes('3.dsc',1);
53     except utils.invalid_dsc_format_exc, line:
54         if line != 14:
55             fail("Incorrect line number ('%s') for test #3." % (line));
56     else:
57         fail("Test #3 wasn't recognised as invalid.");
58
59     # No blank lines at all
60     try:
61         utils.parse_changes('4.dsc',1);
62     except utils.invalid_dsc_format_exc, line:
63         if line != 19:
64             fail("Incorrect line number ('%s') for test #4." % (line));
65     else:
66         fail("Test #4 wasn't recognised as invalid.");
67
68     # Extra blank line before signature body
69     try:
70         utils.parse_changes('5.dsc',1);
71     except utils.invalid_dsc_format_exc, line:
72         if line != 15:
73             fail("Incorrect line number ('%s') for test #5." % (line));
74     else:
75         fail("Test #5 wasn't recognised as invalid.");
76
77     # Extra blank line after signature header
78     try:
79         utils.parse_changes('6.dsc',1);
80     except utils.invalid_dsc_format_exc, line:
81         if line != 5:
82             fail("Incorrect line number ('%s') for test #6." % (line));
83     else:
84         fail("Test #6 wasn't recognised as invalid.");
85
86     # Valid .dsc ; ignoring errors
87     utils.parse_changes('1.dsc', 0);
88
89     # Invalid .dsc ; ignoring errors
90     utils.parse_changes('2.dsc', 0);
91
92 ################################################################################
93
94 if __name__ == '__main__':
95     main()