diff tests/doctest.txt @ 29:1c963875e6cd

add a test for manifest and fix resulting bugs
author Jeff Hammel <jhammel@mozilla.com>
date Tue, 15 Nov 2011 10:13:47 -0800
parents 63ff1b00ec05
children
line wrap: on
line diff
--- a/tests/doctest.txt	Mon Nov 14 22:12:49 2011 -0800
+++ b/tests/doctest.txt	Tue Nov 15 10:13:47 2011 -0800
@@ -7,6 +7,7 @@
     >>> import os
     >>> import shutil
     >>> import tempfile
+    >>> from StringIO import StringIO
 
 Create a staging directory::
 
@@ -15,14 +16,31 @@
 Create a Fetch object::
 
     >>> f = fetch.Fetch(relative_to=stage, strict=True)
-    
+
 Call Fetch directly::
 
     >>> def url(*args):
     ...     return 'file://' + os.path.join(*([here] + list(args)))
     >>> f(url=url('sample1.txt'), destination=stage, type='file')
-    >>> file(os.path.join(stage, 'sample1.txt')).read().strip()
+    >>> dest = os.path.join(stage, 'sample1.txt')
+    >>> file(dest).read().strip()
     'sample1'
+    >>> os.remove(dest)
+
+Parse a Fetch "manifest"::
+
+    >>> dest = os.path.join(stage, 'example1.txt')
+    >>> manifest = '%s %s file' % (url('sample1.txt'), 'example1.txt') # SOURCE DEST TYPE
+    >>> buffer = StringIO()
+    >>> buffer.write(manifest)
+    >>> buffer.seek(0)
+    >>> contents = fetch.read_manifests(buffer)
+    >>> len(contents)
+    1
+    >>> f.fetch(*contents)
+    >>> file(dest).read().strip()
+    'sample1'
+    >>> os.remove(dest)
 
 Cleanup::