X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Ftest%2F006%2Ftest.py;fp=dak%2Ftest%2F006%2Ftest.py;h=0000000000000000000000000000000000000000;hb=47955ee9a5730c81b21ca9f31da4c176a82bcdc4;hp=51a33170aac504711eab42b25d7efe973a53527d;hpb=0113a3259ee2c5395e61ee7939268c5d91d45ac4;p=dak.git diff --git a/dak/test/006/test.py b/dak/test/006/test.py deleted file mode 100755 index 51a33170..00000000 --- a/dak/test/006/test.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -# Test textutils.fix_maintainer() -# Copyright (C) 2004, 2006 James Troup - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -################################################################################ - -import os, sys - -sys.path.append(os.path.abspath('../../')) - -import textutils - -################################################################################ - -def fail(message): - sys.stderr.write("%s\n" % (message)) - sys.exit(1) - -################################################################################ - -def check_valid(s, xa, xb, xc, xd): - (a, b, c, d) = textutils.fix_maintainer(s) - if a != xa: - fail("rfc822_maint: %s (returned) != %s (expected [From: '%s']" % (a, xa, s)) - if b != xb: - fail("rfc2047_maint: %s (returned) != %s (expected [From: '%s']" % (b, xb, s)) - if c != xc: - fail("name: %s (returned) != %s (expected [From: '%s']" % (c, xc, s)) - if d != xd: - fail("email: %s (returned) != %s (expected [From: '%s']" % (d, xd, s)) - -def check_invalid(s): - try: - textutils.fix_maintainer(s) - fail("%s was parsed successfully but is expected to be invalid." % (s)) - except utils.ParseMaintError, unused: - pass - -def main (): - # Check Valid UTF-8 maintainer field - s = "Noèl Köthe " - xa = "Noèl Köthe " - xb = "=?utf-8?b?Tm/DqGwgS8O2dGhl?= " - xc = "Noèl Köthe" - xd = "noel@debian.org" - check_valid(s, xa, xb, xc, xd) - - # Check valid ISO-8859-1 maintainer field - s = "Noèl Köthe " - xa = "Noèl Köthe " - xb = "=?iso-8859-1?q?No=E8l_K=F6the?= " - xc = "Noèl Köthe" - xd = "noel@debian.org" - check_valid(s, xa, xb, xc, xd) - - # Check valid ASCII maintainer field - s = "James Troup " - xa = "James Troup " - xb = "James Troup " - xc = "James Troup" - xd = "james@nocrew.org" - check_valid(s, xa, xb, xc, xd) - - # Check "Debian vs RFC822" fixup of names with '.' or ',' in them - s = "James J. Troup " - xa = "james@nocrew.org (James J. Troup)" - xb = "james@nocrew.org (James J. Troup)" - xc = "James J. Troup" - xd = "james@nocrew.org" - check_valid(s, xa, xb, xc, xd) - s = "James J, Troup " - xa = "james@nocrew.org (James J, Troup)" - xb = "james@nocrew.org (James J, Troup)" - xc = "James J, Troup" - xd = "james@nocrew.org" - check_valid(s, xa, xb, xc, xd) - - # Check just-email form - s = "james@nocrew.org" - xa = " " - xb = " " - xc = "" - xd = "james@nocrew.org" - check_valid(s, xa, xb, xc, xd) - - # Check bracketed just-email form - s = "" - xa = " " - xb = " " - xc = "" - xd = "james@nocrew.org" - check_valid(s, xa, xb, xc, xd) - - # Check Krazy quoted-string local part email address - s = "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>" - xa = "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>" - xb = "Cris van Pelt <\"Cris van Pelt\"@tribe.eu.org>" - xc = "Cris van Pelt" - xd = "\"Cris van Pelt\"@tribe.eu.org" - check_valid(s, xa, xb, xc, xd) - - # Check empty string - s = xa = xb = xc = xd = "" - check_valid(s, xa, xb, xc, xd) - - # Check for missing email address - check_invalid("James Troup") - # Check for invalid email address - check_invalid("James Troup