示例#1
0
 def test_request_patching_duplicate(self):
     """
     Requesting the same patch more than once registers only once.
     """
     db_patch.request_patching(
         [db_patch.XMLRpcLibPatch, db_patch.XMLRpcLibPatch])
     self.assertEqual(len(db_patch.requested_patches), 1)
示例#2
0
 def test_xmlrpclib_failure_without_patch(self):
     """
     Test that without the XMLRpcLibPatch, we get a failure when
     xmlrpclib tries to parse a response that contains Apache's
     extended types.
     """
     db_patch.request_patching(db_patch.XMLRpcLibPatch)
     self.assertTrue(self.db_admin.create_group('foo'))
     # The group is actually removed but the response cannot be parsed.
     self.db_admin.server.removeGroup('foo')
示例#3
0
import os

import requests
from django.conf import settings
import pyexistdb.db
from pyexistdb import patch
from pyexistdb.exceptions import ExistDBException
from . import xquery

patch.request_patching(patch.XMLRpcLibPatch)


class ExistDB(pyexistdb.db.ExistDB):
    def getDocument(self, name):
        # This does pretty much what the default getDocument does
        # but it adds the _indent=no parameter.
        pyexistdb.db.logger.debug('getDocument %s' % self.restapi_path(name))
        response = self.session.get(self.restapi_path(name),
                                    stream=False,
                                    params={"_indent": "no"},
                                    **self.session_opts)
        if response.status_code == requests.codes.ok:
            return response.content
        if response.status_code == requests.codes.not_found:
            raise ExistDBException('%s not found' % name)

    # Note that there is no atomicity here. It would be possible for
    # removeCollection to fail because the collection does not exist
    # and then hasCollection to succeed because another process
    # created the collection in-between.
    def removeCollection(self, collection_name, ignore_nonexistent=False):
示例#4
0
 def test_patch_is_requested(self):
     """
     A patch is requested once the call has been made.
     """
     db_patch.request_patching(db_patch.XMLRpcLibPatch)
     self.assertTrue(db_patch.XMLRpcLibPatch.requested())
示例#5
0
 def test_request_patching_list(self):
     """
     We can request a list of patches.
     """
     db_patch.request_patching([db_patch.XMLRpcLibPatch, Foo])
     self.assertEqual(len(db_patch.requested_patches), 2)
示例#6
0
 def test_request_patching_single_class(self):
     """
     We can request a single patch.
     """
     db_patch.request_patching(db_patch.XMLRpcLibPatch)
     self.assertEqual(len(db_patch.requested_patches), 1)