[Zope3-checkins] CVS: Products3/z3checkins/tests - mbox.txt:1.1 sample_import_msg.txt:1.1 sample_msg1.txt:1.1 sample_msg2.txt:1.1 simple_msg.txt:1.1 svn_msg.txt:1.1 svn_msg2.txt:1.1 svn_msg3.txt:1.1 test_message.py:1.17

Gintautas Miliauskas gintas at pov.lt
Tue Feb 10 09:23:30 EST 2004


Update of /cvs-repository/Products3/z3checkins/tests
In directory cvs.zope.org:/tmp/cvs-serv29167/tests

Modified Files:
	test_message.py 
Added Files:
	mbox.txt sample_import_msg.txt sample_msg1.txt sample_msg2.txt 
	simple_msg.txt svn_msg.txt svn_msg2.txt svn_msg3.txt 
Log Message:
* Now mbox files can be imported.
* Testing messages extracted into separate files.
* The message object's name is forced to be the same as the message's id.
* Updated unit tests.
* Now message ID's are stripped of angled brackets
* Fixed a bug with message subject parsing.


=== Added File Products3/z3checkins/tests/mbox.txt ===
>From steve at cat-box.net  Sat Jun  1 00:31:53 2002
From: steve at cat-box.net (Steve Alexander)
Date: Fri, 31 May 2002 19:31:53 -0400
Subject: [Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security - PermissionRegistry.py:1.1.2.16.14.1
Message-ID: <200205312331.g4VNVr927566 at cvs.baymountain.com>

Update of /cvs-repository/Zope3/lib/python/Zope/App/Security
In directory cvs.zope.org:/tmp/cvs-serv27552

Modified Files:
      Tag: Zope3InWonderland-branch
        PermissionRegistry.py 
Log Message:
Permission ids must not start with a dot.


=== Zope3/lib/python/Zope/App/Security/PermissionRegistry.py 1.1.2.16 => 1.1.2.16.14.1 ===
         """Define a new permission object, register, and return it.
 
-        name is the permission name, must be globally unique
+        permission is the permission name, must be globally unique
 
         title is the permission title, human readable.
 
         description (optional) is human readable
         """
+        if permission.startswith('.'):
+            raise ValueError("permissions must not start with a '.'")
         return self.register(permission, title, description)
 
     def definedPermission(self, permission_id):




>From steve at cat-box.net  Sat Jun  1 00:31:53 2002
From: steve at cat-box.net (Steve Alexander)
Date: Fri, 31 May 2002 19:31:53 -0400
Subject: [Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/tests - testPermissionRegistry.py:1.1.2.13.14.1
Message-ID: <200205312331.g4VNVr027568 at cvs.baymountain.com>

Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/tests
In directory cvs.zope.org:/tmp/cvs-serv27552/tests

Modified Files:
      Tag: Zope3InWonderland-branch
        testPermissionRegistry.py 
Log Message:
Permission ids must not start with a dot.


=== Zope3/lib/python/Zope/App/Security/tests/testPermissionRegistry.py 1.1.2.13 => 1.1.2.13.14.1 ===
         self.assertEqual(None, permissionRegistry.getPermission('Foo'))
         self.failIf(permissionRegistry.definedPermission('Foo'))
+        
+    def testPermissionStartsWithDot(self):
+        self.assertRaises(ValueError, permissionRegistry.definePermission,
+                          '.Foo', 'dot foo title')
 
     def testPermissionIsAnIPermission(self):
         permissionRegistry.definePermission('Foo', 'foo title')
@@ -56,7 +60,7 @@
         permission = permissionRegistry.getPermission('Foo')
         eq(permission.getTitle(), 'Foo-able')
         eq(permission.getDescription(), 'A foo-worthy permission')
-    
+
 
 def test_suite():
     loader=unittest.TestLoader()




>From tim.one at comcast.net  Sat Jun  1 00:46:53 2002
From: tim.one at comcast.net (Tim Peters)
Date: Fri, 31 May 2002 19:46:53 -0400
Subject: [Zope-Checkins] CVS: Zope/lib/python/BTrees/tests - testSetOps.py:1.3
Message-ID: <200205312346.g4VNkr731412 at cvs.baymountain.com>

Update of /cvs-repository/Zope/lib/python/BTrees/tests
In directory cvs.zope.org:/tmp/cvs-serv30763/tests

Modified Files:
        testSetOps.py 
Log Message:
testBigInput():  This spent almost all of its time building an IISet
from a sequence of ints in reverse-sorted order (a quadratic-time
proposition).  That doesn't test anything interesting in context, though.
So fiddled it to do a larger input, but it runs much faster now.


=== Zope/lib/python/BTrees/tests/testSetOps.py 1.2 => 1.3 ===
 
     def testBigInput(self):
-        input = IISet(range(50000))
-        reversed = range(50000)
-        reversed.reverse()
-        reversed = IISet(reversed)
-        output = multiunion([input, reversed] * 5)
-        self.assertEqual(len(output), 50000)
-        self.assertEqual(list(output), range(50000))
+        N = 100000
+        input = IISet(range(N))
+        output = multiunion([input] * 10)
+        self.assertEqual(len(output), N)
+        self.assertEqual(output.minKey(), 0)
+        self.assertEqual(output.maxKey(), N-1)
+        self.assertEqual(list(output), range(N))
 
     def testLotsOfLittleOnes(self):
         from random import shuffle




>From tim.one at comcast.net  Sat Jun  1 01:49:19 2002
From: tim.one at comcast.net (Tim Peters)
Date: Fri, 31 May 2002 20:49:19 -0400
Subject: [Zope-Checkins] CVS: Zope/lib/python/BTrees - SetOpTemplate.c:1.16
Message-ID: <200206010049.g510nJR14723 at cvs.baymountain.com>

Update of /cvs-repository/Zope/lib/python/BTrees
In directory cvs.zope.org:/tmp/cvs-serv14639

Modified Files:
        SetOpTemplate.c 
Log Message:
multiunion():  For an input that's IIBucket-based (IIBucket and IISet),
this now copies the keys into the work area in one gulp via memcpy,
instead of iterating over them one at a time.  Yields a nice speedup when
it applies (and it usually should apply!).


=== Zope/lib/python/BTrees/SetOpTemplate.c 1.15 => 1.16 ===
        set.  At this point, we ignore the possibility of duplicates. */
     for (i = 0; i < n; ++i) {
-        SetIteration setiter = {0, 0, 0};
-        int merge;  /* dummy needed for initSetIteration */
-
         set = PySequence_GetItem(seq, i);
         if (set == NULL)
             goto Error;
 
-        /* XXX TODO: If set is a bucket, do a straight resize+memcpy instead.
-        */
-        if (initSetIteration(&setiter, set, 1, &merge) < 0)
-            goto Error;
-        if (setiter.next(&setiter) < 0)
-            goto Error;
-        while (setiter.position >= 0) {
-            if (result->len >= result->size && Bucket_grow(result, -1, 1) < 0)
+        /* If set is a bucket, do a straight resize + memcpy. */
+        if (set->ob_type == (PyTypeObject*)&SetType ||
+            set->ob_type == (PyTypeObject*)&BucketType) {
+            const int setsize = SIZED(set)->len;
+            int size_desired = result->len + setsize;
+            /* If there are more to come, overallocate by 25% (arbitrary). */
+            if (i < n-1)
+                size_desired += size_desired >> 2;
+            if (size_desired && size_desired > result->size) {
+                if (Bucket_grow(result, size_desired, 1) < 0)
+                    goto Error;
+            }
+            memcpy(result->keys + result->len,
+                   BUCKET(set)->keys,
+                   setsize * sizeof(KEY_TYPE));
+            result->len += setsize;
+        }
+        else {
+            /* No cheap way:  iterate over set's elements one at a time. */
+            SetIteration setiter = {0, 0, 0};
+            int merge;  /* dummy needed for initSetIteration */
+            
+            if (initSetIteration(&setiter, set, 1, &merge) < 0)
                 goto Error;
-            COPY_KEY(result->keys[result->len], setiter.key);
-            ++result->len;
-            /* We know the key is an int, so no need to incref it. */
             if (setiter.next(&setiter) < 0)
                 goto Error;
+            while (setiter.position >= 0) {
+                if (result->len >= result->size && Bucket_grow(result, -1, 1) < 0)
+                    goto Error;
+                COPY_KEY(result->keys[result->len], setiter.key);
+                ++result->len;
+                /* We know the key is an int, so no need to incref it. */
+                if (setiter.next(&setiter) < 0)
+                    goto Error;
+            }
         }
         Py_DECREF(set);
         set = NULL;


=== Added File Products3/z3checkins/tests/sample_import_msg.txt ===
From: Foo Bar <foo.bar at bar.com>
Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - Imported sources
Date: Fri, 28 Mar 2003 11:58:05 +03:00
Message-Id: <42 at bar.com>

Update of /cvs-repository/Zope3/src/foo/bar
In directory cvs.zope.org:/tmp/cvs-serv12345

Log message:
Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
lineum furum testum logum messageum.

Status:

Vendor Tag:\tbarfulator
Release Tags:\tyo-yo

N Zope3/src/foo/bar/baz.py
N Zope3/src/foo/bar/bar.pt

No conflicts created by this import



=== Added File Products3/z3checkins/tests/sample_msg1.txt ===
From: Foo Bar <foo.bar at bar.com>
Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - baz.py:1.2
Date: Fri, 28 Mar 2003 11:58:05 +03:00
Message-Id: <42 at bar.com>

Update of /cvs-repository/Zope3/src/foo/bar
In directory cvs.zope.org:/tmp/cvs-serv12345

Modified files:
        baz.py
Log message:
Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
lineum furum testum logum messageum.


=== Zope3/src/foo/bar/baz.py 1.1 => 1.2 ===
--- Zope3/src/foo/bar/baz.py:1.1    Tue Mar 25 15:21:29 2003
+++ Zope3/src/foo/bar/baz.py        Fri Mar 28 11:57:34 2003
@@@ -123,7 +123,7 @@
 lalala
 burbur
 barbar
-xxx
+yyy
 www
 quux
 furumburum


_______________________________________________
Zope3-Checkins mailing list
Zope3-Checkins at zope.org
http://mail.zope.org/mailman/listinfo/zope3-checkins


=== Added File Products3/z3checkins/tests/sample_msg2.txt ===
From: Foo Bar <foo.bar at bar.com>
Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - baz.py:1.2
Date: Fri, 28 Mar 2003 11:58:05 +03:00
Message-Id: <42 at bar.com>

Update of /cvs-repository/Zope3/src/foo/bar
In directory cvs.zope.org:/tmp/cvs-serv12345

Added files:
      Tag: foo-branch
        baz.py
Log Message:
Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
lineum furum testum logum messageum.


=== Added File Zope3/src/foo/bar/baz.py 1.1 ===
lalala
burbur
barbar



=== Added File Products3/z3checkins/tests/simple_msg.txt ===
From: John Doe <john at example.com>
Subject: Something happened!
Date: Wed, 29 Jul 2003 14:42:11 +0200
Message-Id: <q$w$e$r$t$y at example.com>

This is just a simple message.



=== Added File Products3/z3checkins/tests/svn_msg.txt ===
To: checkins at lists.schooltool.org
From: Albertas Agejevas <alga at pov.lt>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-Id: <20030908101551.6F900C32F at mail.pov.lt>
Date: Mon,  8 Sep 2003 13:15:51 +0300 (EEST)
Subject: [schooltool-checkins] rev 10 - trunk/schooltool

Author: alga
Date: 2003-09-08 13:15:50 +0300 (Mon, 08 Sep 2003)
New Revision: 10

Modified:
   trunk/schooltool/README
Log:
Added a period.


Modified: trunk/schooltool/README
===================================================================
--- trunk/schooltool/README	2003-09-05 16:54:07 UTC (rev 9)
+++ trunk/schooltool/README	2003-09-08 10:15:50 UTC (rev 10)
@@ -1,7 +1,7 @@
 SchoolTool
 ==========
 
-SchoolTool - common information systems platform for school administration
+SchoolTool - common information systems platform for school administration.
 
 Website: http://www.schooltool.org/
 

_______________________________________________
Checkins mailing list
Checkins at lists.schooltool.org
http://lists.schooltool.org/mailman/listinfo/checkins



=== Added File Products3/z3checkins/tests/svn_msg2.txt ===
To: checkins at lists.schooltool.org
From: Albertas Agejevas <alga at pov.lt>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-Id: <20030908101551.6F900C32F at mail.pov.lt>
Date: Mon,  8 Sep 2003 13:15:51 +0300 (EEST)
Subject: [schooltool-checkins] rev 10 -
	trunk/schooltool

Author: alga
Date: 2003-09-08 13:15:50 +0300 (Mon, 08 Sep 2003)
New Revision: 10

Modified:
   trunk/schooltool/README
Log:
Added a period.


Modified: trunk/schooltool/README
===================================================================
--- trunk/schooltool/README	2003-09-05 16:54:07 UTC (rev 9)
+++ trunk/schooltool/README	2003-09-08 10:15:50 UTC (rev 10)
@@ -1,7 +1,7 @@
 SchoolTool
 ==========
 
-SchoolTool - common information systems platform for school administration
+SchoolTool - common information systems platform for school administration.
 
 Website: http://www.schooltool.org/
 

_______________________________________________
Checkins mailing list
Checkins at lists.schooltool.org
http://lists.schooltool.org/mailman/listinfo/checkins



=== Added File Products3/z3checkins/tests/svn_msg3.txt ===
To: checkins at lists.schooltool.org
From: Albertas Agejevas <alga at pov.lt>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Message-Id: <20030909101551.6F900C32F at mail.pov.lt>
Date: Mon,  8 Sep 2003 13:15:51 +0300 (EEST)
Subject: [schooltool-checkins] rev 10 had a bug in it

Blah blah blah

_______________________________________________
Checkins mailing list
Checkins at lists.schooltool.org
http://lists.schooltool.org/mailman/listinfo/checkins



=== Products3/z3checkins/tests/test_message.py 1.16 => 1.17 ===
--- Products3/z3checkins/tests/test_message.py:1.16	Tue Jan 13 12:08:55 2004
+++ Products3/z3checkins/tests/test_message.py	Tue Feb 10 09:23:29 2004
@@ -10,7 +10,6 @@
 import sys
 import time
 from difflib import SequenceMatcher
-from StringIO import StringIO
 from datetime import datetime, timedelta
 from zope.app.tests.placelesssetup import PlacelessSetup
 from zope.component import getService, servicenames
@@ -107,178 +106,6 @@
 
 class TestCheckinMessageParser(unittest.TestCase):
 
-    sample_msg1 = """\
-From: Foo Bar <foo.bar at bar.com>
-Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - baz.py:1.2
-Date: Fri, 28 Mar 2003 11:58:05 +03:00
-Message-Id: <42 at bar.com>
-
-Update of /cvs-repository/Zope3/src/foo/bar
-In directory cvs.zope.org:/tmp/cvs-serv12345
-
-Modified files:
-        baz.py
-Log message:
-Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
-lineum furum testum logum messageum.
-
-
-=== Zope3/src/foo/bar/baz.py 1.1 => 1.2 ===
---- Zope3/src/foo/bar/baz.py:1.1    Tue Mar 25 15:21:29 2003
-+++ Zope3/src/foo/bar/baz.py        Fri Mar 28 11:57:34 2003
-@@@ -123,7 +123,7 @@
- lalala
- burbur
- barbar
--xxx
-+yyy
- www
- quux
- furumburum
-
-
-_______________________________________________
-Zope3-Checkins mailing list
-Zope3-Checkins at zope.org
-http://mail.zope.org/mailman/listinfo/zope3-checkins
-"""
-
-    sample_msg2 = """\
-From: Foo Bar <foo.bar at bar.com>
-Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - baz.py:1.2
-Date: Fri, 28 Mar 2003 11:58:05 +03:00
-Message-Id: <42 at bar.com>
-
-Update of /cvs-repository/Zope3/src/foo/bar
-In directory cvs.zope.org:/tmp/cvs-serv12345
-
-Added files:
-      Tag: foo-branch
-        baz.py
-Log Message:
-Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
-lineum furum testum logum messageum.
-
-
-=== Added File Zope3/src/foo/bar/baz.py 1.1 ===
-lalala
-burbur
-barbar
-"""
-
-    sample_import_msg = """\
-From: Foo Bar <foo.bar at bar.com>
-Subject: [Zope3-checkins] CVS: Zope3/src/foo/bar - Imported sources
-Date: Fri, 28 Mar 2003 11:58:05 +03:00
-Message-Id: <42 at bar.com>
-
-Update of /cvs-repository/Zope3/src/foo/bar
-In directory cvs.zope.org:/tmp/cvs-serv12345
-
-Log message:
-Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
-lineum furum testum logum messageum.
-
-Status:
-
-Vendor Tag:\tbarfulator
-Release Tags:\tyo-yo
-
-N Zope3/src/foo/bar/baz.py
-N Zope3/src/foo/bar/bar.pt
-
-No conflicts created by this import
-"""
-
-    simple_msg = """\
-From: John Doe <john at example.com>
-Subject: Something happened!
-Date: Wed, 29 Jul 2003 14:42:11 +0200
-Message-Id: <q$w$e$r$t$y at example.com>
-
-This is just a simple message.
-"""
-
-    svn_msg = """\
-To: checkins at lists.schooltool.org
-From: Albertas Agejevas <alga at pov.lt>
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-Message-Id: <20030908101551.6F900C32F at mail.pov.lt>
-Date: Mon,  8 Sep 2003 13:15:51 +0300 (EEST)
-Subject: [schooltool-checkins] rev 10 - trunk/schooltool
-
-Author: alga
-Date: 2003-09-08 13:15:50 +0300 (Mon, 08 Sep 2003)
-New Revision: 10
-
-Modified:
-   trunk/schooltool/README
-Log:
-Added a period.
-
-
-Modified: trunk/schooltool/README
-===================================================================
---- trunk/schooltool/README	2003-09-05 16:54:07 UTC (rev 9)
-+++ trunk/schooltool/README	2003-09-08 10:15:50 UTC (rev 10)
-@@ -1,7 +1,7 @@
- SchoolTool
- ==========
- 
--SchoolTool - common information systems platform for school administration
-+SchoolTool - common information systems platform for school administration.
- 
- Website: http://www.schooltool.org/
- 
-
-_______________________________________________
-Checkins mailing list
-Checkins at lists.schooltool.org
-http://lists.schooltool.org/mailman/listinfo/checkins
-"""
-
-    svn_msg_with_split_subject = """\
-To: checkins at lists.schooltool.org
-From: Albertas Agejevas <alga at pov.lt>
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-Message-Id: <20030908101551.6F900C32F at mail.pov.lt>
-Date: Mon,  8 Sep 2003 13:15:51 +0300 (EEST)
-Subject: [schooltool-checkins] rev 10 -
-\ttrunk/schooltool
-
-Author: alga
-Date: 2003-09-08 13:15:50 +0300 (Mon, 08 Sep 2003)
-New Revision: 10
-
-Modified:
-   trunk/schooltool/README
-Log:
-Added a period.
-
-
-Modified: trunk/schooltool/README
-===================================================================
---- trunk/schooltool/README	2003-09-05 16:54:07 UTC (rev 9)
-+++ trunk/schooltool/README	2003-09-08 10:15:50 UTC (rev 10)
-@@ -1,7 +1,7 @@
- SchoolTool
- ==========
- 
--SchoolTool - common information systems platform for school administration
-+SchoolTool - common information systems platform for school administration.
- 
- Website: http://www.schooltool.org/
- 
-
-_______________________________________________
-Checkins mailing list
-Checkins at lists.schooltool.org
-http://lists.schooltool.org/mailman/listinfo/checkins
-"""
-
-
     def test_interface(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         verifyObject(IMessageParser, CheckinMessageParser())
@@ -286,10 +113,13 @@
     def test_parser1(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        sample_msg1 = open_test_data("sample_msg1.txt")
+        sample_msg1_text = sample_msg1.read()
+        sample_msg1.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.sample_msg1))
+        msg = parser.parse(sample_msg1)
         self.assert_(ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<42 at bar.com>")
+        self.assertEquals(msg.message_id, "42 at bar.com")
         self.assertEquals(msg.author, "Foo Bar <foo.bar at bar.com>")
         self.assertEquals(msg.author_name, "Foo Bar")
         self.assertEquals(msg.author_email, "foo.bar at bar.com")
@@ -301,15 +131,18 @@
 Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
 lineum furum testum logum messageum.""")
         self.assertEquals(msg.body,
-                          self.sample_msg1.split("\n\n", 1)[1])
+                          sample_msg1_text.split("\n\n", 1)[1])
 
     def test_parser2(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        sample_msg2 = open_test_data("sample_msg2.txt")
+        sample_msg2_text = sample_msg2.read()
+        sample_msg2.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.sample_msg2))
+        msg = parser.parse(sample_msg2)
         self.assert_(ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<42 at bar.com>")
+        self.assertEquals(msg.message_id, "42 at bar.com")
         self.assertEquals(msg.author, "Foo Bar <foo.bar at bar.com>")
         self.assertEquals(msg.author_name, "Foo Bar")
         self.assertEquals(msg.author_email, "foo.bar at bar.com")
@@ -321,15 +154,19 @@
 Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
 lineum furum testum logum messageum.""")
         self.assertEquals(msg.body,
-                          self.sample_msg2.split("\n\n", 1)[1])
+                          sample_msg2_text.split("\n\n", 1)[1])
+
 
     def test_parser_importmsg(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        sample_import_msg = open_test_data("sample_import_msg.txt")
+        sample_import_msg_text = sample_import_msg.read()
+        sample_import_msg.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.sample_import_msg))
+        msg = parser.parse(sample_import_msg)
         self.assert_(ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<42 at bar.com>")
+        self.assertEquals(msg.message_id, "42 at bar.com")
         self.assertEquals(msg.author, "Foo Bar <foo.bar at bar.com>")
         self.assertEquals(msg.author_name, "Foo Bar")
         self.assertEquals(msg.author_email, "foo.bar at bar.com")
@@ -341,30 +178,36 @@
 Ipsum suum dolores quantum est er nonsensicum textum writum esmum inum tuum
 lineum furum testum logum messageum.""")
         self.assertEquals(msg.body,
-                          self.sample_import_msg.split("\n\n", 1)[1])
+                          sample_import_msg_text.split("\n\n", 1)[1])
 
     def test_parser_simplemsg(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        simple_msg = open_test_data("simple_msg.txt")
+        simple_msg_text = simple_msg.read()
+        simple_msg.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.simple_msg))
+        msg = parser.parse(simple_msg)
         self.assert_(IMessage.isImplementedBy(msg))
         self.assert_(not ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<q$w$e$r$t$y at example.com>")
+        self.assertEquals(msg.message_id, "q$w$e$r$t$y at example.com")
         self.assertEquals(msg.author, "John Doe <john at example.com>")
         self.assertEquals(msg.author_name, "John Doe")
         self.assertEquals(msg.author_email, "john at example.com")
         self.assertEquals(msg.date, datetime(2003, 07, 29, 14, 42, 11,
                                              tzinfo=FixedTimezone(2*60)))
-        self.assertEquals(msg.body, self.simple_msg.split("\n\n", 1)[1])
+        self.assertEquals(msg.body, simple_msg_text.split("\n\n", 1)[1])
 
     def test_parser_svnmsg(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        svn_msg = open_test_data("svn_msg.txt")
+        svn_msg_text = svn_msg.read()
+        svn_msg.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.svn_msg))
+        msg = parser.parse(svn_msg)
         self.assert_(ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<20030908101551.6F900C32F at mail.pov.lt>")
+        self.assertEquals(msg.message_id, "20030908101551.6F900C32F at mail.pov.lt")
         self.assertEquals(msg.author, "Albertas Agejevas <alga at pov.lt>")
         self.assertEquals(msg.author_name, "Albertas Agejevas")
         self.assertEquals(msg.author_email, "alga at pov.lt")
@@ -374,15 +217,18 @@
         self.assertEquals(msg.branch, None)
         self.assertEquals(msg.log_message, """Added a period.""")
         self.assertEquals(msg.body,
-                          self.svn_msg.split("\n\n", 1)[1])
+                          svn_msg_text.split("\n\n", 1)[1])
 
     def test_parser_svnmsg_with_split_subject(self):
         from zopeproducts.z3checkins.message import CheckinMessageParser
         from zopeproducts.z3checkins.message import FixedTimezone
+        svn_msg2 = open_test_data("svn_msg2.txt")
+        svn_msg2_text = svn_msg2.read()
+        svn_msg2.seek(0)
         parser = CheckinMessageParser()
-        msg = parser.parse(StringIO(self.svn_msg_with_split_subject))
+        msg = parser.parse(svn_msg2)
         self.assert_(ICheckinMessage.isImplementedBy(msg))
-        self.assertEquals(msg.message_id, "<20030908101551.6F900C32F at mail.pov.lt>")
+        self.assertEquals(msg.message_id, "20030908101551.6F900C32F at mail.pov.lt")
         self.assertEquals(msg.author, "Albertas Agejevas <alga at pov.lt>")
         self.assertEquals(msg.author_name, "Albertas Agejevas")
         self.assertEquals(msg.author_email, "alga at pov.lt")
@@ -392,7 +238,24 @@
         self.assertEquals(msg.branch, None)
         self.assertEquals(msg.log_message, """Added a period.""")
         self.assertEquals(msg.body,
-                          self.svn_msg.split("\n\n", 1)[1])
+                          svn_msg2_text.split("\n\n", 1)[1])
+
+    def test_parser_svnmsg_with_rev(self):
+        from zopeproducts.z3checkins.message import CheckinMessageParser
+        from zopeproducts.z3checkins.message import FixedTimezone
+        svn_msg3 = open_test_data("svn_msg3.txt")
+        svn_msg3_text = svn_msg3.read()
+        svn_msg3.seek(0)
+        parser = CheckinMessageParser()
+        msg = parser.parse(svn_msg3)
+        self.assert_(IMessage.isImplementedBy(msg))
+        self.assertEquals(msg.message_id, "20030909101551.6F900C32F at mail.pov.lt")
+        self.assertEquals(msg.author, "Albertas Agejevas <alga at pov.lt>")
+        self.assertEquals(msg.author_name, "Albertas Agejevas")
+        self.assertEquals(msg.author_email, "alga at pov.lt")
+        self.assertEquals(msg.date, datetime(2003, 9, 8, 13, 15, 51,
+                                             tzinfo=FixedTimezone(3*60)))
+        self.assertEquals(msg.body, svn_msg3_text.split("\n\n", 1)[1])
 
 
 class MessageStub:
@@ -400,7 +263,7 @@
     implements(ICheckinMessage, IMessageContained)
 
     def __init__(self, data=None, date=None, body=None, log_message='',
-                       message_id="<message at id>"):
+                       message_id="message at id"):
         self.data = data
         self.date = date
         self.body = body
@@ -475,15 +338,19 @@
     implements(IMessageParser)
 
     def parse(self, data):
-        return MessageStub(data=data)
+        if hasattr(data, 'read'):
+            full_text = data.read()
+        else:
+            full_text = data
+        return MessageStub(data=full_text)
 
 class AddingStub:
 
-    def __init__(self, contentName=None):
-        self.contentName = contentName
+    def __init__(self):
+        self.added = []
 
     def add(self, obj):
-        self.added = obj
+        self.added.append(obj)
 
 class TestMessageUpload(PlacelessSetup, unittest.TestCase):
 
@@ -495,24 +362,34 @@
     def test_createAndAdd(self):
         from zopeproducts.z3checkins.message import MessageUpload
         view = MessageUpload()
-        view.context = AddingStub(contentName="foo")
+        view.context = AddingStub()
         view.add = view.context.add
+        added = view.context.added
+        self.assertEquals(len(added), 0)
         view.createAndAdd({'data': 'Ipsum suum'})
-        self.assertEquals(view.context.contentName, "foo")
-        self.assertEquals(view.context.added.__class__, MessageStub)
-        self.assertEquals(view.context.added.message_id, "<message at id>")
-        self.assertEquals(view.context.added.data, "Ipsum suum")
+        self.assertEquals(len(added), 1)
+        self.assertEquals(added[0].__class__, MessageStub)
+        self.assertEquals(added[0].message_id, "message at id")
+        self.assertEquals(added[0].data, "Ipsum suum")
 
-    def test_createAndAdd_default_name(self):
+    def test_createAndAdd_mbox(self):
         from zopeproducts.z3checkins.message import MessageUpload
         view = MessageUpload()
         view.context = AddingStub()
         view.add = view.context.add
-        view.createAndAdd({'data': 'Ipsum suum'})
-        self.assertEquals(view.context.contentName, "<message at id>")
-        self.assertEquals(view.context.added.__class__, MessageStub)
-        self.assertEquals(view.context.added.message_id, "<message at id>")
-        self.assertEquals(view.context.added.data, "Ipsum suum")
+        added = view.context.added
+        data = open_test_data('mbox.txt').read()
+        self.assertEquals(len(added), 0)
+        view.createAndAdd({'data': data})
+        self.assertEquals(len(added), 4)
+        for message in added:
+            self.assertEquals(message.__class__, MessageStub)
+            self.assertEquals(message.message_id, "message at id")
+
+        self.assertEquals(added[0].data.count("Steve Alexander"), 1)
+        self.assertEquals(added[1].data.count("Steve Alexander"), 1)
+        self.assertEquals(added[2].data.count("Tim Peters"), 1)
+        self.assertEquals(added[3].data.count("Tim Peters"), 1)
 
 
 class IUnitTestPresentation(Interface):
@@ -1147,6 +1024,12 @@
         self.assertEquals(view.last(), m4)
         self.assertEquals(view.next(), None)
         self.assertEquals(view.previous(), m3)
+
+
+def open_test_data(filename):
+    """Open a file relative to the location of this module."""
+    base = os.path.dirname(__file__)
+    return open(os.path.join(base, filename))
 
 
 def test_suite():




More information about the Zope3-Checkins mailing list