• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python test_utils.import_xml函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中metashare.test_utils.import_xml函数的典型用法代码示例。如果您正苦于以下问题:Python import_xml函数的具体用法?Python import_xml怎么用?Python import_xml使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test_index_updates_on_import

 def test_index_updates_on_import(self):
     """
     Verifies that the index is correctly updated when importing a resource.
     """
     self.assert_index_is_empty()
     # import a single resource and save it in the DB
     resource = test_utils.import_xml(SearchIndexUpdateTests.RES_PATH_1)[0]
     resource.storage_object.publication_status = INGESTED
     resource.storage_object.save()
     # make sure the import has automatically changed the search index
     self.assertEqual(
         SearchQuerySet().count(),
         1,
         "After the import of a resource the index must automatically " "have changed and contain that resource.",
     )
     # import another resource and save it in the DB
     resource = test_utils.import_xml(SearchIndexUpdateTests.RES_PATH_2)[0]
     resource.storage_object.publication_status = INGESTED
     resource.storage_object.save()
     # make sure the import has automatically changed the search index
     self.assertEqual(
         SearchQuerySet().count(),
         2,
         "After the import of a resource the index must automatically " "have changed and contain that resource.",
     )
开发者ID:marc1s,项目名称:META-SHARE,代码行数:25,代码来源:test_search.py


示例2: setUpClass

 def setUpClass(cls):
     """
     Import a resource to test the workflow changes for
     """
     LOGGER.info("running '{}' tests...".format(cls.__name__))
     test_utils.set_index_active(False)        
     test_utils.setup_test_storage()
     _test_editor_group = \
         EditorGroup.objects.create(name='test_editor_group')
     _test_manager_group = \
         EditorGroupManagers.objects.create(name='test_manager_group',
                                            managed_group=_test_editor_group)            
     owner = test_utils.create_manager_user(
         'manageruser', '[email protected]', 'secret',
         (_test_editor_group, _test_manager_group))       
     
     # load first resource
     _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH)
     _result = test_utils.import_xml(_fixture)
     _result.editor_groups.add(_test_editor_group)
     _result.owners.add(owner)
     # load second resource
     _fixture = '{0}/repository/test_fixtures/ingested-corpus-AudioVideo-French.xml'.format(ROOT_PATH)
     _result = test_utils.import_xml(_fixture)
     _result.editor_groups.add(_test_editor_group)
     _result.owners.add(owner)
     
     # create a normal user
     test_utils.create_user('user', '[email protected]', 'mypasswd')
开发者ID:Atala,项目名称:META-SHARE,代码行数:29,代码来源:tests.py


示例3: setUp

 def setUp(self):
     """
     Imports a few test resources.
     """
     test_utils.setup_test_storage()
     self.test_res_1 = test_utils.import_xml("{0}/repository/fixtures/testfixture.xml".format(ROOT_PATH))
     self.test_res_2 = test_utils.import_xml("{0}/repository/fixtures/ILSP10.xml".format(ROOT_PATH))
开发者ID:JuliBakagianni,项目名称:CEF-ELRC,代码行数:7,代码来源:test_model.py


示例4: test_case_insensitive_search

 def test_case_insensitive_search(self):
     """
     Asserts that case-insensitive searching is done.
     """
     imported_res = test_utils.import_xml(
         "{}/repository/test_fixtures/" "internal-corpus-Text-EngPers.xml".format(ROOT_PATH)
     )[0]
     imported_res.storage_object.published = True
     imported_res.storage_object.save()
     client = Client()
     # assert that a lower case search for an upper case term succeeds:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "fixture"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that an upper case search for a lower case term succeeds:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "ORIGINALLY"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that a lower case search for a mixed case term succeeds:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "unicode"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that a mixed case search for an upper case term succeeds:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "FiXTuRe"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that a camelCase search for an upper case term succeeds:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "fixTure"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that an all lower case search finds a camelCase term:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "speechsynthesis"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
开发者ID:marc1s,项目名称:META-SHARE,代码行数:34,代码来源:test_search.py


示例5: test_view_count_visible_and_updated_in_search_results

 def test_view_count_visible_and_updated_in_search_results(self):
     """
     Verifies that the view count of a resource is visible and updated in
     the search results list.
     """
     test_res = test_utils.import_xml('{}/repository/test_fixtures/'
                     'internal-corpus-Text-EngPers.xml'.format(ROOT_PATH))
     test_res.storage_object.published = True
     test_res.storage_object.save()
     client = Client()
     # to be on the safe side, clear any existing stats
     LRStats.objects.all().delete()
     # assert that the download/view counts are both zero at first:
     response = client.get(_SEARCH_PAGE_PATH)
     self.assertContains(response, 'title="Number of downloads" /> 0')
     self.assertContains(response, 'title="Number of views" /> 0')
     # view the resource, then go back to the browse page and assert that the
     # view count has changed:
     client.get(test_res.get_absolute_url())
     response = client.get(_SEARCH_PAGE_PATH)
     self.assertContains(response, 'title="Number of downloads" /> 0')
     self.assertContains(response, 'title="Number of views" /> 1')
     # log in, view the resource again, go back to the browse page and then
     # assert that the view count has changed again:
     client.login(username='normaluser', password='secret')
     client.get(test_res.get_absolute_url())
     response = client.get(_SEARCH_PAGE_PATH)
     self.assertContains(response, 'title="Number of downloads" /> 0')
     self.assertContains(response, 'title="Number of views" /> 2')
开发者ID:ELDAELRA,项目名称:META-SHARE-3.1.1,代码行数:29,代码来源:test_search.py


示例6: test_download_count_visible_and_updated_in_search_results

 def test_download_count_visible_and_updated_in_search_results(self):
     """
     Verifies that the download count of a resource is visible and updated in
     the search results list.
     """
     test_res = test_utils.import_xml('{}/repository/fixtures/'
             'downloadable_1_license.xml'.format(ROOT_PATH))
     test_res.storage_object.published = True
     test_res.storage_object.save()
     client = Client()
     client.login(username='normaluser', password='secret')
     # to be on the safe side, clear any existing stats
     LRStats.objects.all().delete()
     # assert that the download/view counts are both zero at first:
     response = client.get(_SEARCH_PAGE_PATH)
     self.assertContains(response, 'title="Number of downloads" /> 0')
     self.assertContains(response, 'title="Number of views" /> 0')
     # view the resource, download it, go back to the browse page and then
     # assert that both view and download counts have changed:
     client.get(test_res.get_absolute_url())
     client.post(
         reverse(views.download, args=(test_res.storage_object.identifier,)),
         { 'in_licence_agree_form': 'True', 'licence_agree': 'True',
           'licence': 'CC-BY-NC-SA' })
     response = client.get(_SEARCH_PAGE_PATH)
     self.assertContains(response, 'title="Number of downloads" /> 1')
     self.assertContains(response, 'title="Number of views" /> 1')
开发者ID:ELDAELRA,项目名称:META-SHARE-3.1.1,代码行数:27,代码来源:test_search.py


示例7: test_cannot_change_publication_status_of_remote_copies

 def test_cannot_change_publication_status_of_remote_copies(self):
     # not even a superuser must change the publication status of a remote
     # resource copy
     superuser = User.objects.create_superuser(
         "superuser", "[email protected]", "secret")
     client = Client()
     client.login(username=superuser.username, password='secret')
     # import a temporary resource to not mess with the other tests and set
     # the copy status to remote
     resource = test_utils.import_xml(
         '{0}/repository/fixtures/ILSP10.xml'.format(ROOT_PATH))
     resource.storage_object.copy_status = REMOTE
     # (1) verify that a status change from published is not possible:
     resource.storage_object.publication_status = PUBLISHED
     resource.storage_object.save()
     client.post(ADMINROOT,
         {"action": "unpublish_action", ACTION_CHECKBOX_NAME: resource.id},
         follow=True)
     # fetch the resource from DB as our object is not up-to-date anymore
     resource = resourceInfoType_model.objects.get(pk=resource.id)
     self.assertEquals('published', resource.publication_status())
     # (2) verify that a status change from ingested is not possible:
     resource.storage_object.publication_status = INGESTED
     resource.storage_object.save()
     client.post(ADMINROOT,
         {"action": "publish_action", ACTION_CHECKBOX_NAME: resource.id},
         follow=True)
     # fetch the resource from DB as our object is not up-to-date anymore
     resource = resourceInfoType_model.objects.get(pk=resource.id)
     self.assertEquals('ingested', resource.publication_status())
开发者ID:Atala,项目名称:META-SHARE,代码行数:30,代码来源:test_status_workflow.py


示例8: test_ingested_LRs_are_not_indexed

 def test_ingested_LRs_are_not_indexed(self):
     test_res = test_utils.import_xml('{}/repository/test_fixtures/ingested/'
         'ingested-corpus-AudioVideo-French.xml'.format(ROOT_PATH))
     test_res.storage_object.publication_status = INGESTED
     test_res.storage_object.save()
     response = Client().get(_SEARCH_PAGE_PATH, data={'q': 'INGESTED'})
     self.assertTemplateUsed(response, 'repository/search.html')
     self.assertContains(response, "No results were found for search query")
开发者ID:ELDAELRA,项目名称:META-SHARE-3.1.1,代码行数:8,代码来源:test_search.py


示例9: import_test_resource

 def import_test_resource(cls, editor_group=None, path=TESTFIXTURE_XML):
     test_utils.setup_test_storage()
     result = test_utils.import_xml(path)
     resource = result[0]
     if not editor_group is None:
         resource.editor_groups.add(editor_group)
         resource.save()
     return resource
开发者ID:marc1s,项目名称:META-SHARE,代码行数:8,代码来源:test_editor.py


示例10: setUp

 def setUp(self):
     """
     Import a resource to test the workflow changes for
     """
     test_utils.setup_test_storage()
     _fixture = '{0}/repo2/fixtures/testfixture.xml'.format(ROOT_PATH)
     _result = test_utils.import_xml(_fixture)
     self.resource_id = _result[0].id
开发者ID:kperi,项目名称:META-SHARE,代码行数:8,代码来源:test_status_workflow.py


示例11: import_test_resource

 def import_test_resource(cls, filename, pub_status, copy_status=MASTER, url=settings.DJANGO_URL):
     _fixture = '{0}/repository/fixtures/{1}'.format(settings.ROOT_PATH, filename)
     resource = test_utils.import_xml(_fixture)
     resource.storage_object.publication_status = pub_status
     resource.storage_object.copy_status = copy_status
     resource.storage_object.source_url = url
     resource.storage_object.save()
     resource.storage_object.update_storage()
     return resource
开发者ID:jvivaldi,项目名称:META-SHARE,代码行数:9,代码来源:tests.py


示例12: setUp

 def setUp(self):
     """
     Set up the email test
     """
     test_utils.setup_test_storage()
     _fixture = '{0}/repository/fixtures/testfixture.xml'.format(ROOT_PATH)
     self.resource = test_utils.import_xml(_fixture)
     self.resource.storage_object.published = True
     self.resource.storage_object.save()
开发者ID:Atala,项目名称:META-SHARE,代码行数:9,代码来源:test_email.py


示例13: testImportELRA

 def testImportELRA(self):      
     """
     run tests on ELRA resources
     """
     _path = '{0}/../misc/testdata/ELRAResources/'.format(ROOT_PATH)
     
     _files = os.listdir(_path)
     for _file in _files:
         _currfile =  "%s%s" % (_path, _file)
         _result = test_utils.import_xml(_currfile)            
         self.assertNotEqual(_result[:2], (None, []))
开发者ID:kperi,项目名称:META-SHARE,代码行数:11,代码来源:test_import.py


示例14: _import_resource

def _import_resource(res_file_name):
    """
    Imports the resource with the given file name; looks for the file in
    the folder recommendations/fixtures/; sets publication status to
    PUBLISHED; returns the resource
    """
    res = test_utils.import_xml(
      '{0}/recommendations/fixtures/{1}'.format(ROOT_PATH, res_file_name))
    res.storage_object.publication_status = PUBLISHED
    res.storage_object.save()
    res.storage_object.update_storage()
    return res
开发者ID:MiltosD,项目名称:CEFELRC,代码行数:12,代码来源:tests.py


示例15: _import_resource

def _import_resource(fixture_name):
    """
    Imports the XML resource description with the given file name.
    
    The new resource is published and the ID is returned.
    """
    _result = test_utils.import_xml('{0}/repository/fixtures/{1}'
                                    .format(ROOT_PATH, fixture_name))
    result = _result[0].id
    resource = resourceInfoType_model.objects.get(pk=result)
    resource.storage_object.published = True
    resource.storage_object.save()
    return result
开发者ID:ljo,项目名称:META-SHARE,代码行数:13,代码来源:test_view.py


示例16: test_save_metadata

 def test_save_metadata(self):
     """
     Tests that the metadata XML is not written to the storage folder for internal
     resources but only when the resource is ingested
     """
     # load test fixture; its initial status is 'internal'
     _result = test_utils.import_xml(TESTFIXTURE_XML)
     resource = resourceInfoType_model.objects.get(pk=_result.id)
     _storage_object = resource.storage_object
     _storage_object.update_storage()
     # initial status is 'internal'
     self.assertTrue(_storage_object.publication_status == INTERNAL)
     # internal resource has no metadata XML stored in storage folder
     self.assertFalse(
       os.path.isfile('{0}/metadata-{1:04d}.xml'.format(
               _storage_object._storage_folder(), _storage_object.revision)))
     # set status to ingested
     _storage_object.publication_status = INGESTED
     _storage_object.update_storage()
     # ingested resource has metadata XML stored in storage folder
     self.assertTrue(
       os.path.isfile('{0}/metadata-{1:04d}.xml'.format(
         _storage_object._storage_folder(), _storage_object.revision)))
     # ingested resource has global part of storage object in storage folder
     self.assertTrue(
       os.path.isfile('{0}/storage-global.json'.format(
         _storage_object._storage_folder())))
     # ingested resource has local part of storage object in storage folder
     self.assertTrue(
       os.path.isfile('{0}/storage-local.json'.format(
         _storage_object._storage_folder())))
     # ingested resource has digest zip in storage folder
     self.assertTrue(
       os.path.isfile('{0}/resource.zip'.format(
         _storage_object._storage_folder())))
     # digest zip contains metadata.xml and storage-global.json
     _zf_name = '{0}/resource.zip'.format( _storage_object._storage_folder())
     _zf = zipfile.ZipFile(_zf_name, mode='r')
     self.assertTrue('metadata.xml' in _zf.namelist())
     self.assertTrue('storage-global.json' in _zf.namelist())
     # md5 of digest zip is stored in storage object
     with ZipFile(_zf_name, 'r') as inzip:
         with inzip.open('metadata.xml') as resource_xml:
             resource_xml_string = resource_xml.read()
         with inzip.open('storage-global.json') as storage_file:
             # read json string
             storage_json_string = storage_file.read() 
         _checksum = compute_digest_checksum(
           resource_xml_string, storage_json_string)
         self.assertEqual(_checksum, _storage_object.digest_checksum)
开发者ID:Atala,项目名称:META-SHARE,代码行数:50,代码来源:test_persistence.py


示例17: init_index_with_a_resource

 def init_index_with_a_resource(self):
     """
     Initializes an empty search index with a single resource.
     
     The imported resource is returned. Asserts that the index really only
     contains a single resource.
     """
     self.assert_index_is_empty()
     # import a single resource and save it in the DB
     resource = test_utils.import_xml(SearchIndexUpdateTests.RES_PATH_1)[0]
     resource.storage_object.save()
     # make sure the import has automatically changed the search index
     self.assertEqual(SearchQuerySet().count(), 1,
         "After the import of a resource the index must automatically " \
         "have changed and contain that resource.")
     return resource
开发者ID:kperi,项目名称:META-SHARE,代码行数:16,代码来源:test_search.py


示例18: test_sitemap

    def test_sitemap(self):
        """
        Tests the correct appearance of the sitemap
        """

        imported_res = test_utils.import_xml("{}/repository/fixtures/" "testfixture.xml".format(ROOT_PATH))
        imported_res.storage_object.published = True
        imported_res.storage_object.save()
        client = Client()

        # Assert that the sitemap page contains the xmlsn and the entry
        # of the imported resource.
        response = client.get(SITEMAP_URL)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">')
        self.assertContains(response, "{}/repository/browse/italian-tts-speech-corpus-appen/".format(DJANGO_URL))
开发者ID:JuliBakagianni,项目名称:CEF-ELRC,代码行数:16,代码来源:test_seo.py


示例19: assert_import_equals_export

 def assert_import_equals_export(self, _roundtrip):
     _result = test_utils.import_xml(_roundtrip)
     with open(_roundtrip) as _import_file:
         _import_xml = _import_file.read()
         register_namespace("", SCHEMA_NAMESPACE)
         _import_xml = to_xml_string(fromstring(_import_xml), encoding="utf-8")
     _export_xml = to_xml_string(_result.export_to_elementtree(), encoding="utf-8")
     # cfedermann: uncomment these lines to dump import/export XML to file.
     #
     # with open('/tmp/_import.xml', 'wb') as _out:
     #    _out.write(_import_xml.encode('utf-8'))
     # with open('/tmp/_export.xml', 'wb') as _out:
     #    _out.write(_export_xml.encode('utf-8'))
     diff = "\n".join(unified_diff(_import_xml.split("\n"), _export_xml.split("\n")))
     self.assertEqual(
         _import_xml, _export_xml, msg="For file {0}, export differs from import:\n{1}".format(_roundtrip, diff)
     )
开发者ID:JuliBakagianni,项目名称:CEF-ELRC,代码行数:17,代码来源:test_model.py


示例20: test_camel_case_aware_search

 def test_camel_case_aware_search(self):
     """
     Asserts that the search engine is camelCase-aware.
     """
     imported_res = test_utils.import_xml(
         "{}/repository/test_fixtures/" "internal-corpus-Text-EngPers.xml".format(ROOT_PATH)
     )[0]
     imported_res.storage_object.published = True
     imported_res.storage_object.save()
     client = Client()
     # assert that a two-token search finds a camelCase term:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "speech synthesis"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
     # assert that a camelCase search term also finds the camelCase term:
     response = client.get("/{0}repository/search/".format(DJANGO_BASE), follow=True, data={"q": "speechSynthesis"})
     self.assertEqual("repository/search.html", response.templates[0].name)
     self.assertContains(response, "1 Language Resource", status_code=200)
开发者ID:marc1s,项目名称:META-SHARE,代码行数:18,代码来源:test_search.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python test_utils.set_index_active函数代码示例发布时间:2022-05-27
下一篇:
Python test_utils.clean_storage函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap