Skip to content

Commit cc09658

Browse files
committed
Fix load tool when authentication credentials are provided.
1 parent 7c86459 commit cc09658

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

couchdb/tests/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import unittest
1010

1111
from couchdb.tests import client, couch_tests, design, http, multipart, \
12-
mapping, view, package
12+
mapping, view, package, tools
1313

1414

1515
def suite():
@@ -22,6 +22,7 @@ def suite():
2222
suite.addTest(view.suite())
2323
suite.addTest(couch_tests.suite())
2424
suite.addTest(package.suite())
25+
suite.addTest(tools.suite())
2526
return suite
2627

2728

couchdb/tests/tools.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2012 Alexander Shorin
4+
# All rights reserved.
5+
#
6+
# This software is licensed as described in the file COPYING, which
7+
# you should have received as part of this distribution.
8+
#
9+
10+
11+
import unittest
12+
from StringIO import StringIO
13+
14+
from couchdb.tools import load
15+
from couchdb.tests import testutil
16+
17+
class ToolLoadTestCase(testutil.TempDatabaseMixin, unittest.TestCase):
18+
19+
def test_handle_credentials(self):
20+
# Issue 194: couchdb-load attribute error: 'Resource' object has no attribute 'http'
21+
# http://code.google.com/p/couchdb-python/issues/detail?id=194
22+
load.load_db(StringIO(''), self.db.resource.url, 'foo', 'bar')
23+
24+
25+
def suite():
26+
suite = unittest.TestSuite()
27+
suite.addTest(unittest.makeSuite(ToolLoadTestCase, 'test'))
28+
return suite
29+
30+
31+
if __name__ == '__main__':
32+
unittest.main(defaultTest='suite')
33+

couchdb/tools/load.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
def load_db(fileobj, dburl, username=None, password=None, ignore_errors=False):
2525
db = Database(dburl)
2626
if username is not None and password is not None:
27-
db.resource.http.add_credentials(username, password)
27+
db.resource.credentials = (username, password)
2828

2929
for headers, is_multipart, payload in read_multipart(fileobj):
3030
docid = headers['content-id']

0 commit comments

Comments
 (0)