Revision: 58b76bbcb082
Branch: default
Author: Alexander Shorin <kxe
...@gmail.com>
Date: Tue Oct 9 01:04:31 2012
Log: Fix load tool when authentication credentials are provided.
http://code.google.com/p/couchdb-python/source/detail?r=58b76bbcb082
Added:
/couchdb/tests/tools.py
Modified:
/couchdb/tests/__init__.py
/couchdb/tools/load.py
=======================================
--- /dev/null
+++ /couchdb/tests/tools.py Tue Oct 9 01:04:31 2012
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2012 Alexander Shorin
+# All rights reserved.
+#
+# This software is licensed as described in the file COPYING, which
+# you should have received as part of this distribution.
+#
+
+
+import unittest
+from StringIO import StringIO
+
+from couchdb.tools import load
+from couchdb.tests import testutil
+
+class ToolLoadTestCase(testutil.TempDatabaseMixin, unittest.TestCase):
+
+ def test_handle_credentials(self):
+ # Issue 194: couchdb-load attribute error: 'Resource' object has
no attribute 'http'
+ # http://code.google.com/p/couchdb-python/issues/detail?id=194
+ load.load_db(StringIO(''), self.db.resource.url, 'foo', 'bar')
+
+
+def suite():
+ suite = unittest.TestSuite()
+ suite.addTest(unittest.makeSuite(ToolLoadTestCase, 'test'))
+ return suite
+
+
+if __name__ == '__main__':
+ unittest.main(defaultTest='suite')
+
=======================================
--- /couchdb/tests/__init__.py Mon Apr 26 03:53:34 2010
+++ /couchdb/tests/__init__.py Tue Oct 9 01:04:31 2012
@@ -9,7 +9,7 @@
import unittest
from couchdb.tests import client, couch_tests, design, http, multipart, \
- mapping, view, package
+ mapping, view, package, tools
def suite():
@@ -22,6 +22,7 @@
suite.addTest(view.suite())
suite.addTest(couch_tests.suite())
suite.addTest(package.suite())
+ suite.addTest(tools.suite())
return suite
=======================================
--- /couchdb/tools/load.py Thu Feb 25 08:00:38 2010
+++ /couchdb/tools/load.py Tue Oct 9 01:04:31 2012
@@ -24,7 +24,7 @@
def load_db(fileobj, dburl, username=None, password=None,
ignore_errors=False):
db = Database(dburl)
if username is not None and password is not None:
- db.resource.http.add_credentials(username, password)
+ db.resource.credentials = (username, password)
for headers, is_multipart, payload in read_multipart(fileobj):
docid = headers['content-id']