当前位置: 首页>>代码示例>>Python>>正文


Python Repository.purge_object方法代码示例

本文整理汇总了Python中eulfedora.server.Repository.purge_object方法的典型用法代码示例。如果您正苦于以下问题:Python Repository.purge_object方法的具体用法?Python Repository.purge_object怎么用?Python Repository.purge_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eulfedora.server.Repository的用法示例。


在下文中一共展示了Repository.purge_object方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: PdfToTextTest

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
class PdfToTextTest(unittest.TestCase):
    fixture_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fixtures')
    pdf_filepath = os.path.join(fixture_dir, 'test.pdf')
    pdf_text = 'This is a short PDF document to use for testing.'

    def setUp(self):
        self.repo = Repository(settings.FEDORA_ROOT, settings.FEDORA_USER,
                               settings.FEDORA_PASSWORD)
        with open(self.pdf_filepath) as pdf:
            self.pdfobj = self.repo.get_object(type=TestPdfObject)
            self.pdfobj.label = 'eulindexer test pdf object'
            self.pdfobj.pdf.content = pdf
            self.pdfobj.save()

    def tearDown(self):
        self.repo.purge_object(self.pdfobj.pid)
        
    def test_file(self):
        # extract text from a pdf from a file on the local filesystem
        text = pdf_to_text(open(self.pdf_filepath, 'rb'))
        self.assertEqual(self.pdf_text, text)

    def test_object_datastream(self):
        # extract text from a pdf datastream in fedora
        pdfobj = self.repo.get_object(self.pdfobj.pid, type=TestPdfObject)
        text = pdf_to_text(pdfobj.pdf.content)
        self.assertEqual(self.pdf_text, text)
开发者ID:jrhoads,项目名称:eulfedora,代码行数:29,代码来源:test_util.py

示例2: ThesisBase

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
class ThesisBase(unittest.TestCase):
    """Base class for testing the functionality of the ETD Django 
     application."""

    def __init__(self, *args, **kwargs):
        unittest.TestCase.__init__(self, *args, **kwargs)
        self.fedora_fixtures_ingested = []
        self.pidspace = FEDORA_PIDSPACE

    def setUp(self):
        """Creates a base class instance of an `eulfedora` Repository 
        for testing the basic functionality of the ingesting
        a thesis object into a Fedora Repository."""
        self.repo = Repository()
#        self.repo = Repository(FEDORA_ROOT,FEDORA_USER,FEDORA_PASSWORD)
        self.repo.risearch.RISEARCH_FLUSH_ON_QUERY = True
    
    def tearDown(self):
        """Removes test objects from the repository"""
        for pid in self.fedora_fixtures_ingested:
            try:
                self.repo.purge_object(pid)
            except RequestFailed as rf:
                logger.warn('Error purging test object %s in tear down:%s' %\
                            (pid,rf)) 
开发者ID:Tutt-Library,项目名称:ccetd,代码行数:27,代码来源:tests.py

示例3: FedoraTestCase

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
class FedoraTestCase(unittest.TestCase):
    def __init__(self, *args, **kwargs):
        unittest.TestCase.__init__(self, *args, **kwargs)
        self.fedora_fixtures_ingested = []
        self.pidspace = FEDORA_PIDSPACE

        self.repo = Repository(FEDORA_ROOT, FEDORA_USER, FEDORA_PASSWORD)

        # fixture cleanup happens in tearDown, which doesn't always run
        # if a test fails - clean up stale test objects from a previous run here
        stale_objects = list(self.repo.find_objects(pid__contains="%s:*" % self.pidspace))
        if stale_objects:
            print "Removing %d stale test object(s) in pidspace %s" % (len(stale_objects), self.pidspace)
            for obj in stale_objects:
                try:
                    self.repo.purge_object(obj.pid)
                except RequestFailed as rf:
                    logger.warn("Error purging stale test object %s (TestCase init): %s" % (obj.pid, rf))

    def setUp(self):
        # NOTE: queries require RI flush=True or test objects will not show up in RI
        self.repo.risearch.RISEARCH_FLUSH_ON_QUERY = True
        self.opener = self.repo.opener
        self.api = ApiFacade(self.opener)
        fixtures = getattr(self, "fixtures", [])
        for fixture in fixtures:
            self.ingestFixture(fixture)

    def tearDown(self):
        for pid in self.fedora_fixtures_ingested:
            try:
                self.repo.purge_object(pid)
            except RequestFailed as rf:
                logger.warn("Error purging test object %s in tear down: %s" % (pid, rf))

    def getNextPid(self):
        pidspace = getattr(self, "pidspace", None)
        return self.repo.get_next_pid(namespace=pidspace)

    def loadFixtureData(self, fname):
        data = load_fixture_data(fname)
        # if pidspace is specified, get a new pid from fedora and set it as the pid in the xml
        if hasattr(self, "pidspace"):
            xml = xmlmap.load_xmlobject_from_string(data, _MinimalFoxml)
            xml.pid = self.getNextPid()
            return xml.serialize()
        else:
            return data

    def ingestFixture(self, fname):
        object = self.loadFixtureData(fname)
        pid = self.repo.ingest(object)
        if pid:
            # we'd like this always to be true. if ingest fails we should
            # throw an exception. that probably hasn't been thoroughly
            # tested yet, though, so we'll check it until it has been.
            self.append_test_pid(pid)

    def append_test_pid(self, pid):
        self.fedora_fixtures_ingested.append(pid)
开发者ID:kwbock,项目名称:eulfedora,代码行数:62,代码来源:base.py

示例4: purge_item

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
def purge_item(item_id):
    repo = Repository()
    pid = 'pitt:%s' % (item_id,)
    objs = repo.find_objects(pid__contains=pid)
    for o in objs:
        repo.purge_object(o.pid)
        print '%s purged' % (o.pid,)
开发者ID:abrennr,项目名称:drlrepo,代码行数:9,代码来源:purge_object.py

示例5: remove_test_objects

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
    def remove_test_objects(self):
        # remove any leftover test object before or after running tests
        # NOTE: This method expects to be called only when FEDORA_PIDSPACE has been
        # switched to a test pidspace

        # use test fedora credentials if they are set
        repo = Repository(root=getattr(settings, 'FEDORA_TEST_ROOT', None),
                          username=getattr(settings, 'FEDORA_TEST_USER', None),
                          password=getattr(settings, 'FEDORA_TEST_PASSWORD', None))
        test_objects = repo.find_objects(pid__contains='%s:*' % settings.FEDORA_PIDSPACE)
        count = 0
        for obj in test_objects:
            # if objects are unexpectedly not being cleaned up, pid/label may help
            # to isolate which test is creating the leftover objects
            try:
                repo.purge_object(obj.pid, "removing test object")
                # NOTE: not displaying label because we may not have permission to access it
                logger.info('Purged test object %s' % obj.pid)
                count += 1
            except RequestFailed:
                logger.warn('Error purging test object %s' % obj.pid)
        if count:
            print "Removed %s test object(s) with pidspace %s" % (count, settings.FEDORA_PIDSPACE)
开发者ID:jrhoads,项目名称:eulfedora,代码行数:25,代码来源:testutil.py

示例6: ModelUtilsTest

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
class ModelUtilsTest(TestCase):
    # tests for utility methods declared in file.models

    repo_admin = None

    def setUp(self):
        # instantiate repo_admin the first time we run, after the test settings are in place
        if self.repo_admin is None:
            self.repo_admin = Repository(username=getattr(settings, 'FEDORA_TEST_USER', None),
                                         password=getattr(settings, 'FEDORA_TEST_PASSWORD', None))
        self.pids = []

    def tearDown(self):
        for pid in self.pids:
            self.repo_admin.purge_object(pid)

    def test_object_type_from_mimetype(self):
        self.assertEqual(ImageObject, object_type_from_mimetype('image/jpeg'))
        self.assertEqual(ImageObject, object_type_from_mimetype('image/gif'))
        self.assertEqual(FileObject, object_type_from_mimetype('image/unsupported-img'))
        self.assertEqual(FileObject, object_type_from_mimetype('text/plain'))
        
    def test_init_by_cmodel(self):
        # create file and image objects to test initialization
        fileobj = self.repo_admin.get_object(type=FileObject)
        fileobj.save()
        imgobj = self.repo_admin.get_object(type=ImageObject)
        imgobj.save()
        self.pids.extend([fileobj.pid, imgobj.pid])
        # init a new object from file pid - should be a file object
        initobj = init_by_cmodel(fileobj.pid)
        self.assert_(isinstance(initobj, FileObject))
        # since ImageObject extends FileObject, confirm that we didn't get the wrong thing
        self.assert_(not isinstance(initobj, ImageObject))
        # image pid should be returned as an ImageObject
        initobj = init_by_cmodel(imgobj.pid)
        self.assert_(isinstance(initobj, ImageObject))
开发者ID:emory-libraries,项目名称:genrepo-demo,代码行数:39,代码来源:tests.py

示例7: FedoraStorage

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]

#.........这里部分代码省略.........
        meta = self.read_metadata(doc)
        meta.update(kwargs)
        metacontent = [u"%s=%s" % (k, v) for k, v in meta.iteritems()]
        doc._doc.meta.content = "\n".join(metacontent)

    def attr_uri(self, doc, attr):
        """URI for image datastream."""
        return "%sobjects/%s/datastreams/%s/content" % (
                self.repo.fedora_root,
                urllib.quote(doc.pid),
                getattr(self, "%s_name" % attr)
        )

    def document_label(self, doc):
        """Get the document label."""
        return doc._doc.label

    def document_attr_empty(self, doc, attr):
        """Check if document attr is empty."""
        return getattr(doc._doc, attr).info.size == 0

    def document_attr_label(self, doc, attr):
        """Get label for an image type attribute."""
        return getattr(doc._doc, attr).label

    def document_attr_mimetype(self, doc, attr):
        """Get mimetype for an image type attribute."""
        return getattr(doc._doc, attr).mimetype

    def document_attr_content_handle(self, doc, attr):
        """Get content for an image type attribute."""
        handle = getattr(doc._doc, attr).content
        return StringIO() if handle is None else handle

    def document_metadata(self, doc):
        """Get document metadata. This currently
        just exposes the DC stream attributes."""                
        return self.read_metadata(doc)

    def _set_document_ds_content(self, doc, dsattr, content):
        docattr = getattr(doc._doc, dsattr)
        #checksum = hashlib.md5(content.read()).hexdigest()
        #content.seek(0)
        #docattr.checksum = checksum
        #docattr.checksum_type = "MD5"
        docattr.content = content

    def set_document_attr_content(self, doc, attr, content):
        """Set image content."""
        self._set_document_ds_content(doc, attr, content)

    def set_document_attr_mimetype(self, doc, attr, mimetype):
        """Set image mimetype."""
        getattr(doc._doc, attr).mimetype = mimetype
    
    def set_document_attr_label(self, doc, attr, label):
        """Set image label."""
        getattr(doc._doc, attr).label = label

    def set_document_label(self, doc, label):
        """Set document label."""
        doc._doc.label = label

    def set_document_metadata(self, doc, **kwargs):
        """Set arbitrary document metadata."""
        self.write_metadata(doc, kwargs)

    def save_document(self, doc):
        """Save document."""
        doc._doc.save()

    def create_document(self, label):
        """Get a new document object"""
        dobj = self.repo.get_object(type=self.model)
        dobj.label = label
        dobj.meta.label = "Document Metadata"
        dobj.meta.mimetype = "text/plain"
        doc = FedoraDocument(dobj, self)
        return doc

    def get(self, pid):
        """Get an object by id."""
        doc = self.repo.get_object(pid, type=self.model)
        if doc:
            return FedoraDocument(doc, self)

    def delete(self, doc, msg=None):
        """Delete an object."""
        self.repo.purge_object(doc.pid, log_message=msg)

    def list(self, namespace=None):
        """List documents in the repository."""
        ns = namespace if namespace is not None else self.namespace
        return [FedoraDocument(d, self) \
                for d in self.repo.find_objects("%s:*" % ns, type=self.model)]
        
    def list_pids(self, namespace=None):
        """List of pids.  This unforunately involves calling
        list(), so it not a quicker alternative."""
        return [doc.pid for doc in self.list()]
开发者ID:vitorio,项目名称:ocropodium,代码行数:104,代码来源:fedora.py

示例8: test_index_details

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
    def test_index_details(self):
        repo = Repository()
        for pid in self.pids:
            repo.purge_object(pid)

        # Test with no settings set.
        # - should be denied
        response = index_config(self.request)
        self.assertEqual(403, response.status_code,
            'index data should be forbidden if no IPs are configured to access')

        # NOTE: these aren't meaningful errors anyway, and settings
        # are now being pulled from somewhere so they fail
        # self.assertRaises(AttributeError, index_config, self.request)
        # Test with only the allowed SOLR url set.
        # self.assertRaises(AttributeError, index_config, self.request)

        # Test with this IP not allowed to hit the service.
        #settings.EUL_INDEXER_ALLOWED_IPS = ['0.13.23.134']
        with override_settings(EUL_INDEXER_ALLOWED_IPS=['0.13.23.134']):
            response = index_config(self.request)
            expected, got = 403, response.status_code
            self.assertEqual(expected, got,
                'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
            expected, got = 'text/html', response['Content-Type']
            self.assertEqual(expected, got,
                'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))

        # Test with this IP allowed to hit the view.
        with override_settings(EUL_INDEXER_ALLOWED_IPS=['0.13.23.134',
                                                    self.request_ip]):
            response = index_config(self.request)
            expected, got = 200, response.status_code
            self.assertEqual(expected, got,
                'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
            expected, got = 'application/json', response['Content-Type']
            self.assertEqual(expected, got,
                'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))
            # load json content so we can inspect the result
            content = json.loads(response.content)
            self.assertEqual(TEST_SOLR_URL, content['SOLR_URL'])
            self.assert_(SimpleObject.CONTENT_MODELS in content['CONTENT_MODELS'])
            self.assert_(LessSimpleDigitalObject.CONTENT_MODELS in content['CONTENT_MODELS'])
            self.assert_(ContentModel.CONTENT_MODELS not in content['CONTENT_MODELS'],
               'Fedora system content models should not be included in indexed cmodels by default')

        # Test with the "ANY" setting for allowed IPs
        with override_settings(EUL_INDEXER_ALLOWED_IPS='ANY'):
            response = index_config(self.request)
            expected, got = 200, response.status_code
            self.assertEqual(expected, got,
                'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))

        # Test with 'EUL_INDEXER_CONTENT_MODELS' setting configured to override autodetect.
        with override_settings(EUL_INDEXER_ALLOWED_IPS='ANY',
                               EUL_INDEXER_CONTENT_MODELS=[
                ['content-model_1', 'content-model_2'], ['content-model_3']]):
            response = index_config(self.request)
            expected, got = 200, response.status_code
            self.assertEqual(expected, got,
                'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
            expected, got = 'application/json', response['Content-Type']
            self.assertEqual(expected, got,
                'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))
            # load json content so we can inspect the result
            content = json.loads(response.content)
            self.assertEqual(settings.EUL_INDEXER_CONTENT_MODELS,
                content['CONTENT_MODELS'])
开发者ID:bodleian,项目名称:eulfedora,代码行数:77,代码来源:test_views.py

示例9: handle

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
 def handle(self, *args, **kwargs):
     verbosity = kwargs.get('verbosity', self.v_normal)
     repo = Repository()
     video_duplicates = repo.find_objects(type=Video, label="DELETE")
     for pid in video_duplicates:
         repo.purge_object(pid.pid)
开发者ID:emory-libraries,项目名称:TheKeep,代码行数:8,代码来源:delete_duplicates.py

示例10: print

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
    pids_to_delete.append(etd.pid)
    pid_report.append(etd.related())

    for r in etd.get_related_pids():
        related = etd = repo.get_object(r, type=RelatedRecord)
        if related.check():
            pids_to_delete.append(related.pid)
        else:
            print(related.pid + ' is related to multiple ETDs.')

pp.pprint(pid_report)

if not args['no_action']:
    print(str(len(pids_to_delete)) + ' will be purged.')
    raw_input("Press Enter to continue...")

    for bad_pid in pids_to_delete:
        # TODO add error handeling for a pid that might have already been deleted.
        ark = bad_pid.split(':')[1]
        # Important: we must deactive ark first. Otherwise we'll get a 404 on the uri.
        #try:
        #    client.update_target(type="ark", noid=ark, active=False)
        #except requests.exceptions.HTTPError:
        #    pass
        
        try:
            repo.purge_object(bad_pid)
        except eulfedora.util.RequestFailed:
            pass
开发者ID:emory-libraries,项目名称:ETD,代码行数:31,代码来源:etd-delete-pids.py

示例11: FileViewsTest

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
class FileViewsTest(TestCase):
    fixtures =  ['users']   # re-using collection users fixture & credentials

    # repository with test credentials for loading & removing test objects
    # DON'T instantiate this at load time, since Fedora Test settings are not yet switched
    repo_admin = None
    
    ingest_fname = os.path.join(settings.BASE_DIR, 'file', 'fixtures', 'hello.txt')
    ingest_md5sum = '746308829575e17c3331bbcb00c0898b'   # md5sum of hello.txt 
    image_fname = os.path.join(settings.BASE_DIR, 'file', 'fixtures', 'test.jpg')
    image_md5sum = 'ef7397e4bde82e558044458045bba96a'   # md5sum of test.jpeg
    
    ingest_url = reverse('file:ingest')

    # required django form management metadata for formsets on DC edit form
    edit_mgmt_data = {}
    for field in ['creator', 'contributor', 'coverage', 'relation', 'subject']:
        edit_mgmt_data['%s_list-MAX_NUM_FORMS' % field] = ''
        edit_mgmt_data['%s_list-INITIAL_FORMS' % field] = 0
        edit_mgmt_data['%s_list-TOTAL_FORMS' % field] = 0
    

    def setUp(self):
        # instantiate repo_admin the first time we run, after the test settings are in place
        if self.repo_admin is None:
            self.repo_admin = Repository(username=getattr(settings, 'FEDORA_TEST_USER', None),
                                         password=getattr(settings, 'FEDORA_TEST_PASSWORD', None))

        self.client = Client()

        # create a file object to edit
        with open(self.ingest_fname) as ingest_f:
            self.obj = self.repo_admin.get_object(type=FileObject)
            self.obj.dc.content.title =  self.obj.label = 'Test file object'
            self.obj.dc.content.date =  '2011'
            self.obj.master.content = ingest_f
            self.obj.master.label = 'hello-world.txt'
            self.obj.master.checksum = self.ingest_md5sum
            self.obj.save()
        self.edit_url = reverse('file:edit', kwargs={'pid': self.obj.pid})
        self.download_url = reverse('file:download', kwargs={'pid': self.obj.pid})
        self.view_url = reverse('file:view', kwargs={'pid': self.obj.pid})

        # create a image object for testing
        with open(self.image_fname) as ingest_f:
            self.imgobj = self.repo_admin.get_object(type=FileObject)
            self.imgobj.dc.content.title =  self.imgobj.label = 'Test file object'
            self.imgobj.master.content = ingest_f
            self.imgobj.master.label = 'test.jpg'
            self.imgobj.master.checksum = self.image_md5sum
            self.imgobj.save()

        self.pids = [self.obj.pid, self.imgobj.pid]

    def tearDown(self):
        for pid in self.pids:
            self.repo_admin.purge_object(pid)

    # ingest

    def test_get_ingest_form(self):
        # not logged in - should redirect to login page
        response = self.client.get(self.ingest_url)
        code = response.status_code
        expected = 302
        self.assertEqual(code, expected, 'Expected %s but returned %s for %s as AnonymousUser'
                             % (expected, code, self.ingest_url))

        # logged in as user without required permissions - should 403
        self.client.login(**NONADMIN_CREDENTIALS)
        response = self.client.get(self.ingest_url)
        code = response.status_code
        expected = 403
        self.assertEqual(code, expected,
                         'Expected %s but returned %s for GET %s as logged in non-repo editor'
                         % (expected, code, self.ingest_url))

        # log in as repository editor 
        self.client.post(settings.LOGIN_URL, ADMIN_CREDENTIALS)
        # on GET, form should be displayed
        response = self.client.get(self.ingest_url)
        self.assertEqual(response.status_code, 200)
        self.assertTrue(isinstance(response.context['form'], IngestForm))

        # collection URI passed in via GET should be pre-selected
        collections = IngestForm().fields['collection'].choices
        collection_tuple = collections[1] # 0 is blank. 1 is the first non-blank one
        collection_uri = collection_tuple[0]
        response = self.client.get(self.ingest_url, {'collection': collection_uri})
        self.assertEqual(collection_uri, response.context['form'].initial['collection'],
                         'collection URI specified in GET url parameter should be set as initial value')

    def test_incomplete_ingest_form(self):
        # not logged in - should redirect to login page
        response = self.client.post(self.ingest_url)
        code = response.status_code
        expected = 302
        self.assertEqual(code, expected,
                         'Expected %s but returned %s for POST %s as AnonymousUser'
                         % (expected, code, self.ingest_url))
#.........这里部分代码省略.........
开发者ID:emory-libraries,项目名称:genrepo-demo,代码行数:103,代码来源:tests.py

示例12: tearDownModule

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
def tearDownModule():
    global postcards
    repo = Repository()
    for p in postcards:
        repo.purge_object(p.pid)
开发者ID:emory-libraries-beckctr,项目名称:greatwar,代码行数:7,代码来源:tests.py

示例13: test_index_details

# 需要导入模块: from eulfedora.server import Repository [as 别名]
# 或者: from eulfedora.server.Repository import purge_object [as 别名]
    def test_index_details(self):
        repo = Repository()
        for pid in self.pids:
            repo.purge_object(pid)

        #Test with no settings set.
        self.assertRaises(AttributeError, index_config, self.request)

        #Test with only the allowed SOLR url set.
        solr_url = 'http://localhost:5555'
        settings.SOLR_SERVER_URL = solr_url
        self.assertRaises(AttributeError, index_config, self.request)


        #Test with this IP not allowed to hit the service.
        settings.EUL_INDEXER_ALLOWED_IPS = ['0.13.23.134']
        response = index_config(self.request)
        expected, got = 403, response.status_code
        self.assertEqual(expected, got,
            'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
        expected, got = 'text/html', response['Content-Type']
        self.assertEqual(expected, got,
            'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))
        

        #Test with this IP allowed to hit the view.
        settings.EUL_INDEXER_ALLOWED_IPS = ['0.13.23.134', self.request_ip]
        response = index_config(self.request)
        expected, got = 200, response.status_code
        self.assertEqual(expected, got,
            'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
        expected, got = 'application/json', response['Content-Type']
        self.assertEqual(expected, got,
            'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))
        # load json content so we can inspect the result
        content = simplejson.loads(response.content)
        self.assertEqual(solr_url, content['SOLR_URL'])
        self.assert_(SimpleDigitalObject.CONTENT_MODELS in content['CONTENT_MODELS'])
        self.assert_(LessSimpleDigitalObject.CONTENT_MODELS in content['CONTENT_MODELS'])
        self.assert_(ContentModel.CONTENT_MODELS not in content['CONTENT_MODELS'],
                     'Fedora system content models should not be included in indexed cmodels by default')

        #Test with the "ANY" setting for allowed IPs
        settings.INDEXER_ALLOWED_IPS = 'ANY'
        response = index_config(self.request)
        expected, got = 200, response.status_code
        self.assertEqual(expected, got,
            'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))

        #Test with 'EUL_INDEXER_CONTENT_MODELS' setting configured to override autodetect.
        settings.EUL_INDEXER_CONTENT_MODELS = [['content-model_1', 'content-model_2'], ['content-model_3']]
        response = index_config(self.request)
        expected, got = 200, response.status_code
        self.assertEqual(expected, got,
            'Expected %s but returned %s for indexdata/index_details view' \
                % (expected, got))
        expected, got = 'application/json', response['Content-Type']
        self.assertEqual(expected, got,
            'Expected %s but returned %s for mimetype on indexdata/index_details view' \
                % (expected, got))
        # load json content so we can inspect the result
        content = simplejson.loads(response.content)
        self.assertEqual(settings.EUL_INDEXER_CONTENT_MODELS, content['CONTENT_MODELS'])
开发者ID:jrhoads,项目名称:eulfedora,代码行数:70,代码来源:test_views.py


注:本文中的eulfedora.server.Repository.purge_object方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。