Hello community, here is the log from the commit of package python-couchdbkit for openSUSE:Factory checked in at 2013-09-27 18:00:30 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-couchdbkit (Old) and /work/SRC/openSUSE:Factory/.python-couchdbkit.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-couchdbkit" Changes: -------- --- /work/SRC/openSUSE:Factory/python-couchdbkit/python-couchdbkit.changes 2012-06-26 17:53:16.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.python-couchdbkit.new/python-couchdbkit.changes 2013-09-27 18:00:31.000000000 +0200 @@ -1,0 +2,8 @@ +Fri Sep 27 00:16:29 UTC 2013 - [email protected] + +- Update to version 0.6.5 + + Upstream provides no changelog, see + https://github.com/benoitc/couchdbkit/compare/0.6.3...0.6.5 +- Replace python-distribute with python-setuptools + +------------------------------------------------------------------- Old: ---- couchdbkit-0.6.3.tar.gz New: ---- couchdbkit-0.6.5.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-couchdbkit.spec ++++++ --- /var/tmp/diff_new_pack.iCGNUm/_old 2013-09-27 18:00:31.000000000 +0200 +++ /var/tmp/diff_new_pack.iCGNUm/_new 2013-09-27 18:00:31.000000000 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-couchdbkit # -# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,7 +16,7 @@ # Name: python-couchdbkit -Version: 0.6.3 +Version: 0.6.5 Release: 0 Url: http://couchdbkit.org Summary: Python couchdb kit @@ -25,7 +25,7 @@ Source: http://pypi.python.org/packages/source/c/couchdbkit/couchdbkit-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRequires: python-devel -BuildRequires: python-distribute +BuildRequires: python-setuptools Requires: python-restkit Suggests: couchdb %if 0%{?suse_version} && 0%{?suse_version} <= 1110 ++++++ couchdbkit-0.6.3.tar.gz -> couchdbkit-0.6.5.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/PKG-INFO new/couchdbkit-0.6.5/PKG-INFO --- old/couchdbkit-0.6.3/PKG-INFO 2012-06-06 09:26:08.000000000 +0200 +++ new/couchdbkit-0.6.5/PKG-INFO 2013-08-30 22:35:17.000000000 +0200 @@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: couchdbkit -Version: 0.6.3 +Version: 0.6.5 Summary: Python couchdb kit Home-page: http://couchdbkit.org Author: Benoit Chesneau diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/__init__.py new/couchdbkit-0.6.5/couchdbkit/__init__.py --- old/couchdbkit-0.6.3/couchdbkit/__init__.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/__init__.py 2013-08-30 17:43:49.000000000 +0200 @@ -26,7 +26,7 @@ DocumentSchema, DocumentBase, Document, StaticDocument, contain, QueryMixin, AttachmentMixin, SchemaProperty, SchemaListProperty, SchemaDictProperty, - ListProperty, DictProperty, StringListProperty, SetProperty + ListProperty, DictProperty, StringDictProperty, StringListProperty, SetProperty ) import logging diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/client.py new/couchdbkit-0.6.5/couchdbkit/client.py --- old/couchdbkit-0.6.3/couchdbkit/client.py 2012-06-06 08:26:11.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/client.py 2013-08-30 22:24:18.000000000 +0200 @@ -248,8 +248,8 @@ @param server: Server instance """ - self.uri = uri - self.server_uri, self.dbname = uri.rsplit("/", 1) + self.uri = uri.rstrip('/') + self.server_uri, self.dbname = self.uri.rsplit("/", 1) if server is not None: if not hasattr(server, 'next_uuid'): @@ -307,25 +307,40 @@ def flush(self): """ Remove all docs from a database except design docs.""" + # save ddocs all_ddocs = self.all_docs(startkey="_design", endkey="_design/"+u"\u9999", include_docs=True) ddocs = [] for ddoc in all_ddocs: - attachments = ddoc['doc'].get('_attachments', {}) - for name, info in attachments.items(): - info['data'] = self.fetch_attachment(ddoc['doc'], name) - del info['stub'] + doc = ddoc['doc'] + old_atts = doc.get('_attachments', {}) + atts = {} + for name, info in old_atts.items(): + att = {} + att['content_type'] = info['content_type'] + att['data'] = self.fetch_attachment(ddoc['doc'], name) + atts[name] = att + + # create a fresh doc + doc.pop('_rev') + doc['_attachments'] = resource.encode_attachments(atts) - ddoc['doc'].pop('_rev') - ddocs.append(ddoc['doc']) + ddocs.append(doc) # delete db self.server.delete_db(self.dbname) # we let a chance to the system to sync - time.sleep(0.2) + times = 0 + while times < 10: + try: + self.server.res.head('/%s/' % self.dbname) + except ResourceNotFound: + break + time.sleep(0.2) + times += 1 # recreate db + ddocs self.server.create_db(self.dbname) @@ -724,7 +739,7 @@ def search( self, view_name, handler='_fti/_design', wrapper=None, schema=None, **params): """ Search. Return results from search. Use couchdb-lucene with its default settings by default.""" - return ViewResults(self, self.raw_view, + return ViewResults(self.raw_view, "/%s/%s" % (handler, view_name), wrapper=wrapper, schema=schema, params=params) @@ -984,6 +999,9 @@ self._dynamic_keys = [] self._result_cache = self.fetch_raw().json_body + assert isinstance(self._result_cache, dict), 'received an invalid ' \ + 'response of type %s: %s' % \ + (type(self._result_cache), repr(self._result_cache)) self._total_rows = self._result_cache.get('total_rows') self._offset = self._result_cache.get('offset', 0) @@ -1032,6 +1050,14 @@ return ViewResults(self._fetch, self._arg, wrapper=self.wrapper, params=params, schema=None) + def __call__(self, **newparams): + return ViewResults( + self._fetch, self._arg, + wrapper=self.wrapper, + params=dict(self.params, **newparams), + schema=None, + ) + def __iter__(self): return self.iterator() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/consumer/sync.py new/couchdbkit-0.6.5/couchdbkit/consumer/sync.py --- old/couchdbkit-0.6.3/couchdbkit/consumer/sync.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/consumer/sync.py 2013-08-30 09:55:55.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 - # -# This file is part of couchdbkit released under the MIT license. +# This file is part of couchdbkit released under the MIT license. # See the NOTICE for more information. from __future__ import with_statement @@ -22,17 +22,17 @@ with resp.body_stream() as body: while True: data = body.read() - if not data: + if not data: break buf += data - + ret = json.loads(buf) if cb is not None: cb(ret) return return ret - + def wait(self, cb, **params): check_callable(cb) params.update({"feed": "continuous"}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/designer/fs.py new/couchdbkit-0.6.5/couchdbkit/designer/fs.py --- old/couchdbkit-0.6.3/couchdbkit/designer/fs.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/designer/fs.py 2013-08-30 10:04:18.000000000 +0200 @@ -429,7 +429,7 @@ docs1 = [] for doc in e.errors: try: - doc['_rev'] = db.last_rev(doc['_id']) + doc['_rev'] = db.get_rev(doc['_id']) docs1.append(doc) except ResourceNotFound: pass @@ -483,7 +483,7 @@ else: newdoc = doc.copy() try: - rev = db.last_rev(doc['_id']) + rev = db.get_rev(doc['_id']) newdoc.update({'_rev': rev}) except ResourceNotFound: pass @@ -495,7 +495,7 @@ docs1 = [] for doc in e.errors: try: - doc['_rev'] = db.last_rev(doc['_id']) + doc['_rev'] = db.get_rev(doc['_id']) docs1.append(doc) except ResourceNotFound: pass diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/exceptions.py new/couchdbkit-0.6.5/couchdbkit/exceptions.py --- old/couchdbkit-0.6.3/couchdbkit/exceptions.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/exceptions.py 2013-08-30 22:18:21.000000000 +0200 @@ -6,7 +6,7 @@ """ All exceptions used in couchdbkit. """ -from restkit.errors import ResourceError +from restkit.errors import ResourceError, RequestFailed class InvalidAttachment(Exception): """ raised when an attachment is invalid """ @@ -59,3 +59,8 @@ class PreconditionFailed(ResourceError): """ Exception raised when 412 HTTP error is received in response to a request """ + +class DocTypeError(Exception): + """ Exception raised when doc type of json to be wrapped + does not match the doc type of the matching class + """ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/ext/django/loading.py new/couchdbkit-0.6.5/couchdbkit/ext/django/loading.py --- old/couchdbkit-0.6.3/couchdbkit/ext/django/loading.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/ext/django/loading.py 2013-08-30 22:24:18.000000000 +0200 @@ -58,10 +58,10 @@ for app_name, app_setting in databases.iteritems(): uri = app_setting['URL'] - # Blank credentials are valid for the admin party - user = app_setting.get('USER', '') - password = app_setting.get('PASSWORD', '') - auth = BasicAuth(user, password) + # Do not send credentials when they are both None as admin party will give a 401 + user = app_setting.get('USER') + password = app_setting.get('PASSWORD') + filters = [BasicAuth(user, password)] if (user or password) is not None else [] try: if isinstance(uri, (list, tuple)): @@ -75,7 +75,7 @@ raise ValueError("couchdb uri [%s:%s] invalid" % ( app_name, uri)) - res = CouchdbResource(server_uri, timeout=COUCHDB_TIMEOUT, filters=[auth]) + res = CouchdbResource(server_uri, timeout=COUCHDB_TIMEOUT, filters=filters) server = Server(server_uri, resource_instance=res) app_label = app_name.split('.')[-1] @@ -137,8 +137,16 @@ This is used to reduce the waiting time for blocking view updates """ app_name = app.__name__.rsplit('.', 1)[0] - app_label = app_name.split('.')[-1] - if app_label in self._databases: + app_labels = set() + schema_list = self.app_schema.values() + for schema_dict in schema_list: + for schema in schema_dict.values(): + app_module = schema.__module__.rsplit(".", 1)[0] + if app_module == app_name and not schema._meta.app_label in app_labels: + app_labels.add(schema._meta.app_label) + for app_label in app_labels: + if not app_label in self._databases: + continue if verbosity >=1: print "Copy prepared design docs for `%s`" % app_name db = self.get_db(app_label) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/ext/django/schema.py new/couchdbkit-0.6.5/couchdbkit/ext/django/schema.py --- old/couchdbkit-0.6.3/couchdbkit/ext/django/schema.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/ext/django/schema.py 2013-08-30 17:43:49.000000000 +0200 @@ -37,8 +37,8 @@ 'value_to_python', 'dict_to_python', 'list_to_python', 'convert_property', 'DocumentSchema', 'Document', 'SchemaProperty', 'SchemaListProperty', 'ListProperty', - 'DictProperty', 'StringListProperty', 'SchemaDictProperty', - 'SetProperty',] + 'DictProperty', 'StringDictProperty', 'StringListProperty', + 'SchemaDictProperty', 'SetProperty',] DEFAULT_NAMES = ('verbose_name', 'db_table', 'ordering', @@ -169,6 +169,7 @@ SchemaListProperty = schema.SchemaListProperty ListProperty = schema.ListProperty DictProperty = schema.DictProperty +StringDictProperty = schema.StringDictProperty StringListProperty = schema.StringListProperty SchemaDictProperty = schema.SchemaDictProperty SetProperty = schema.SetProperty diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/schema/__init__.py new/couchdbkit-0.6.5/couchdbkit/schema/__init__.py --- old/couchdbkit-0.6.3/couchdbkit/schema/__init__.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/schema/__init__.py 2013-08-30 17:43:49.000000000 +0200 @@ -168,6 +168,7 @@ DateProperty, TimeProperty, DictProperty, + StringDictProperty, ListProperty, StringListProperty, SetProperty, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/schema/base.py new/couchdbkit-0.6.5/couchdbkit/schema/base.py --- old/couchdbkit-0.6.3/couchdbkit/schema/base.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/schema/base.py 2013-08-30 17:49:21.000000000 +0200 @@ -99,7 +99,7 @@ if _d is not None: if not isinstance(_d, dict): - raise TypeError('d should be a dict') + raise TypeError('_d should be a dict') properties.update(_d) doc_type = getattr(self, '_doc_type', self.__class__.__name__) @@ -404,7 +404,7 @@ docid = kwargs.pop('_id', _d.pop("_id", "")) docrev = kwargs.pop('_rev', _d.pop("_rev", "")) - DocumentSchema.__init__(self, _d, **kwargs) + super(DocumentBase, self).__init__(_d, **kwargs) if docid: self._doc['_id'] = valid_id(docid) if docrev: self._doc['_rev'] = docrev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/schema/properties.py new/couchdbkit-0.6.5/couchdbkit/schema/properties.py --- old/couchdbkit-0.6.3/couchdbkit/schema/properties.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/schema/properties.py 2013-08-30 17:43:49.000000000 +0200 @@ -25,15 +25,15 @@ __all__ = ['ALLOWED_PROPERTY_TYPES', 'Property', 'StringProperty', 'IntegerProperty', 'DecimalProperty', 'BooleanProperty', 'FloatProperty', 'DateTimeProperty', 'DateProperty', - 'TimeProperty', 'DictProperty', 'ListProperty', - 'StringListProperty', + 'TimeProperty', 'DictProperty', 'StringDictProperty', + 'ListProperty', 'StringListProperty', 'dict_to_json', 'list_to_json', 'value_to_json', 'MAP_TYPES_PROPERTIES', 'value_to_python', 'dict_to_python', 'list_to_python', 'convert_property', 'value_to_property', 'LazyDict', 'LazyList'] if support_setproperty: - __all__ += ['SetProperty', 'LasySet'] + __all__ += ['SetProperty', 'LazySet'] ALLOWED_PROPERTY_TYPES = set([ basestring, @@ -452,6 +452,22 @@ +class StringDictProperty(DictProperty): + + def to_python(self, value): + return LazyDict(value, item_type=basestring) + + def validate_dict_contents(self, value): + try: + value = validate_dict_content(value, basestring) + except BadValueError: + raise BadValueError( + 'Items of %s dict must all be in %s' % + (self.name, basestring)) + return value + + + class ListProperty(Property): """A property that stores a list of things. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/schema/properties_proxy.py new/couchdbkit-0.6.5/couchdbkit/schema/properties_proxy.py --- old/couchdbkit-0.6.3/couchdbkit/schema/properties_proxy.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/schema/properties_proxy.py 2013-08-30 09:55:55.000000000 +0200 @@ -5,8 +5,7 @@ """ Meta properties """ - -from ..exceptions import BadValueError +from ..exceptions import BadValueError from .base import DocumentSchema from .properties import Property @@ -70,7 +69,7 @@ self._use_instance = use_instance self._schema = schema - + def default_value(self): if not self._use_instance: if self.default: @@ -96,15 +95,9 @@ raise BadValueError( 'Property %s must be DocumentSchema instance, not a %s' % (self.name, type(value).__name__)) - return value def to_python(self, value): - if not self._use_instance: - schema = self._schema() - else: - schema = self._schema.clone() - if not self._use_instance: schema = self._schema else: @@ -159,7 +152,7 @@ def validate_list_schema(self, value, required=True): for v in value: - v.validate(required=required) + v.validate(required=required) return value def default_value(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/schema/util.py new/couchdbkit-0.6.5/couchdbkit/schema/util.py --- old/couchdbkit-0.6.3/couchdbkit/schema/util.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/schema/util.py 2013-08-30 22:18:21.000000000 +0200 @@ -1,3 +1,4 @@ +from couchdbkit.exceptions import DocTypeError def schema_map(schema, dynamic_properties): @@ -26,7 +27,15 @@ def wrap(doc): doc_type = doc.get(doctype_attr) - cls = classes[doc_type] + try: + cls = classes[doc_type] + except KeyError: + raise DocTypeError( + "the document being wrapped has doc type {0!r}. " + "To wrap it anyway, you must explicitly pass in " + "classes={{{0!r}: <document class>}} to your view. " + "This behavior is new starting in 0.6.2.".format(doc_type) + ) return cls.wrap(doc) return wrap diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/utils.py new/couchdbkit-0.6.5/couchdbkit/utils.py --- old/couchdbkit-0.6.3/couchdbkit/utils.py 2012-05-21 08:46:36.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/utils.py 2013-08-30 09:55:55.000000000 +0200 @@ -20,18 +20,23 @@ try: - import simplejson as json + import ujson as json + except ImportError: + try: - import json + import simplejson as json except ImportError: - raise ImportError("""simplejson isn't installed + try: + import json + except ImportError: + raise ImportError("""simplejson isn't installed + + Install it with the command: -Install it with the command: + pip install simplejson + """) - pip install simplejson -""") - # backport relpath from python2.6 if not hasattr(os.path, 'relpath'): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit/version.py new/couchdbkit-0.6.5/couchdbkit/version.py --- old/couchdbkit-0.6.3/couchdbkit/version.py 2012-06-06 09:20:18.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit/version.py 2013-08-30 22:26:13.000000000 +0200 @@ -3,5 +3,5 @@ # This file is part of couchdbkit released under the MIT license. # See the NOTICE for more information. -version_info = (0, 6, 3) +version_info = (0, 6, 5) __version__ = ".".join(map(str, version_info)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit.egg-info/PKG-INFO new/couchdbkit-0.6.5/couchdbkit.egg-info/PKG-INFO --- old/couchdbkit-0.6.3/couchdbkit.egg-info/PKG-INFO 2012-06-06 09:26:08.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit.egg-info/PKG-INFO 2013-08-30 22:35:17.000000000 +0200 @@ -1,6 +1,6 @@ -Metadata-Version: 1.0 +Metadata-Version: 1.1 Name: couchdbkit -Version: 0.6.3 +Version: 0.6.5 Summary: Python couchdb kit Home-page: http://couchdbkit.org Author: Benoit Chesneau diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/couchdbkit.egg-info/requires.txt new/couchdbkit-0.6.5/couchdbkit.egg-info/requires.txt --- old/couchdbkit-0.6.3/couchdbkit.egg-info/requires.txt 2012-06-06 09:26:08.000000000 +0200 +++ new/couchdbkit-0.6.5/couchdbkit.egg-info/requires.txt 2013-08-30 22:35:17.000000000 +0200 @@ -1,2 +1 @@ -restkit>=4.1.3 -nose \ No newline at end of file +restkit>=4.2.2 \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/setup.py new/couchdbkit-0.6.5/setup.py --- old/couchdbkit-0.6.3/setup.py 2012-06-06 00:37:45.000000000 +0200 +++ new/couchdbkit-0.6.5/setup.py 2013-08-30 17:43:49.000000000 +0200 @@ -51,10 +51,7 @@ zip_safe = False, - install_requires = [ - 'restkit>=4.1.3', - 'nose' - ], + install_requires = [ 'restkit>=4.2.2' ], entry_points=""" [couchdbkit.consumers] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/tests/client_test.py new/couchdbkit-0.6.5/tests/client_test.py --- old/couchdbkit-0.6.3/tests/client_test.py 2012-06-06 08:30:28.000000000 +0200 +++ new/couchdbkit-0.6.5/tests/client_test.py 2013-08-30 17:49:21.000000000 +0200 @@ -646,6 +646,12 @@ assert 'limit' not in viewres.params limited = viewres[1:2] + def test_view_subview(self): + db = self.Server.create_db('couchdbkit_test') + viewres = db.view('test/test') + assert not viewres.params + subviewres = viewres(key='a') + self.assert_(subviewres.params) def testAllDocs(self): db = self.Server.create_db('couchdbkit_test') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/tests/test_changes.py new/couchdbkit-0.6.5/tests/test_changes.py --- old/couchdbkit-0.6.3/tests/test_changes.py 2012-06-05 17:34:38.000000000 +0200 +++ new/couchdbkit-0.6.5/tests/test_changes.py 2013-08-30 09:55:55.000000000 +0200 @@ -80,12 +80,12 @@ self.db.save_doc(doc) self.db.ensure_full_commit() - time.sleep(1.0) + time.sleep(0.3) self.assert_(len(lines) == 5) self.assert_(lines[4]["id"] == "test4") doc = {"_id": "test5"} self.db.save_doc(doc) - time.sleep(1.0) + time.sleep(0.3) self.assert_(len(lines) == 6) self.assert_(lines[5]["id"] == "test5") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/tests/test_consumer.py new/couchdbkit-0.6.5/tests/test_consumer.py --- old/couchdbkit-0.6.3/tests/test_consumer.py 2012-05-21 08:46:37.000000000 +0200 +++ new/couchdbkit-0.6.5/tests/test_consumer.py 2013-08-30 09:55:55.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 - # -# This file is part of couchdbkit released under the MIT license. +# This file is part of couchdbkit released under the MIT license. # See the NOTICE for more information. # __author__ = '[email protected] (BenoƮt Chesneau)' @@ -15,7 +15,7 @@ from couchdbkit import * class ClientServerTestCase(unittest.TestCase): - + def setUp(self): self.server = Server() self._delete_db() @@ -24,14 +24,14 @@ def tearDown(self): self._delete_db() - + def _delete_db(self): try: del self.server['couchdbkit_test'] except: pass - + def test_fetch(self): res1 = self.consumer.fetch() self.assert_("last_seq" in res1) @@ -43,15 +43,15 @@ self.assert_(res2["last_seq"] == 1) self.assert_(len(res2["results"]) == 1) line = res2["results"][0] - self.assert_(line["id"] == doc["_id"]) - + self.assert_(line["id"] == doc["_id"]) + def test_longpoll(self): - + def test_line(line): self.assert_(line["last_seq"] == 1) self.assert_(len(line["results"]) == 1) return - + t = threading.Thread(target=self.consumer.wait_once, kwargs=dict(cb=test_line)) t.daemon = True @@ -63,25 +63,25 @@ self.lines = [] def test_line(line): self.lines.append(line) - + t = threading.Thread(target=self.consumer.wait, kwargs=dict(cb=test_line)) t.daemon = True t.start() - + for i in range(5): doc = {"_id": "test%s" % str(i)} self.db.save_doc(doc) self.db.ensure_full_commit() - time.sleep(0.5) + time.sleep(0.3) self.assert_(len(self.lines) == 5) self.assert_(self.lines[4]["id"] == "test4") doc = {"_id": "test5"} self.db.save_doc(doc) - time.sleep(0.5) + time.sleep(0.3) self.assert_(len(self.lines) == 6) self.assert_(self.lines[5]["id"] == "test5") - + if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/couchdbkit-0.6.3/tests/test_schema.py new/couchdbkit-0.6.5/tests/test_schema.py --- old/couchdbkit-0.6.3/tests/test_schema.py 2012-05-21 08:46:37.000000000 +0200 +++ new/couchdbkit-0.6.5/tests/test_schema.py 2013-08-30 22:18:21.000000000 +0200 @@ -444,6 +444,30 @@ self.assert_(isinstance(results2.first(), TestDoc) == True) self.server.delete_db('couchdbkit_test') + def test_wrong_doc_type(self): + db = self.server.create_db('couchdbkit_test') + try: + class Foo(Document): + _db = db + pass + + class Bar(Foo): + pass + + Bar().save() + + result = Bar.view('_all_docs', include_docs=True) + self.assertEqual(len(result), 1) + bar, = result.all() + self.assertIsInstance(bar, Bar) + + result = Foo.view('_all_docs', include_docs=True) + self.assertEqual(len(result), 1) + from couchdbkit.exceptions import DocTypeError + with self.assertRaises(DocTypeError): + result.all() + finally: + self.server.delete_db('couchdbkit_test') def testOne(self): class TestDoc(Document): -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
