本文整理汇总了Python中atramhasis.views.views.AtramhasisView类的典型用法代码示例。如果您正苦于以下问题:Python AtramhasisView类的具体用法?Python AtramhasisView怎么用?Python AtramhasisView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AtramhasisView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_passing_view
def test_passing_view(self):
request = testing.DummyRequest()
request.skos_registry = self.regis
atramhasisview = AtramhasisView(request)
info = atramhasisview.home_view()
self.assertIsNotNone(info['conceptschemes'][0])
self.assertEqual(info['conceptschemes'][0]['id'], 'TREES')
示例2: test_passing_view
def test_passing_view(self):
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
response = atramhasisview.favicon_view()
self.assertEqual(response.status_int, 200)
self.assertIn('image/x-icon', response.headers['Content-Type'])
self.assertIsNotNone(response.body)
示例3: test_default_locale
def test_default_locale(self):
config_default_lang = settings.get('pyramid.default_locale_name')
self.request.referer = None
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + config_default_lang))
示例4: test_no_schema
def test_no_schema(self):
self.request.matchdict['scheme_id'] = 'GG'
self.request.params = MultiDict()
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
info = atramhasisview.search_result()
self.assertEqual(info.status_int, 404)
示例5: test_no_type
def test_no_type(self):
request = self.request
request.matchdict['scheme_id'] = 'TREES'
request.matchdict['c_id'] = '555'
request.skos_registry = self.regis
atramhasisview = AtramhasisView(request)
info = atramhasisview.concept_view()
self.assertEqual(info.status_int, 500)
示例6: test_conceptschemes_view
def test_conceptschemes_view(self):
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.conceptschemes_view()
self.assertIn('conceptschemes', res)
self.assertEqual(len(res['conceptschemes']), 1)
cs = res['conceptschemes'][0]
self.assertIn('id', cs)
self.assertIn('conceptscheme', cs)
示例7: test_locale_uppercase
def test_locale_uppercase(self):
testlang = 'it'
self.request.GET['language'] = testlang.upper()
self.request.referer = None
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + testlang))
示例8: test_no_querystring
def test_no_querystring(self):
self.request.matchdict['scheme_id'] = 'TREES'
self.request.params = MultiDict()
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
info = atramhasisview.search_result()
self.assertIsNotNone(info['concepts'])
self.assertEqual(len(info['concepts']), 3)
示例9: test_unsupported_lang
def test_unsupported_lang(self):
config_default_lang = settings.get('pyramid.default_locale_name')
request = testing.DummyRequest()
request.GET['language'] = 'XX'
request.referer = None
request.skos_registry = self.regis
atramhasisview = AtramhasisView(request)
res = atramhasisview.set_locale_cookie()
self.assertTrue((res.headers.get('Set-Cookie')).startswith('_LOCALE_=' + config_default_lang))
示例10: test_csv
def test_csv(self):
self.request.matchdict['scheme_id'] = 'TREES'
self.request.params = MultiDict()
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.results_csv()
self.assertEqual(res['filename'], 'atramhasis_export')
self.assertIsInstance(res['header'], list)
self.assertIsInstance(res['rows'], list)
self.assertEqual(2, len(res['rows']))
示例11: test_passing_collection_view
def test_passing_collection_view(self):
request = self.request
request.matchdict['scheme_id'] = 'TREES'
request.matchdict['c_id'] = '3'
request.skos_registry = self.regis
atramhasisview = AtramhasisView(request)
info = atramhasisview.concept_view()
self.assertIsNotNone(info['concept'])
self.assertEqual(info['conceptType'], 'Collection')
self.assertEqual(info['scheme_id'], 'TREES')
示例12: test_referer
def test_referer(self):
testlang = 'it'
testurl = 'http://www.foo.bar'
self.request.GET['language'] = testlang.upper()
self.request.referer = testurl
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.set_locale_cookie()
self.assertEqual(res.status, '302 Found')
self.assertEqual(res.location, testurl)
示例13: test_conceptscheme_view
def test_conceptscheme_view(self):
self.request.matchdict['scheme_id'] = 'TREES'
atramhasisview = AtramhasisView(self.request)
res = atramhasisview.conceptscheme_view()
self.assertIsNotNone(res)
self.assertIsNotNone(res['conceptscheme'])
self.assertEqual(res['conceptscheme']['title'], 'TREES')
self.assertEqual(res['conceptscheme']['scheme_id'], 'TREES')
self.assertEqual(res['conceptscheme']['uri'], 'urn:x-skosprovider:trees')
self.assertIsNotNone(res['conceptscheme']['labels'])
self.assertIsNotNone(res['conceptscheme']['notes'])
self.assertIsNotNone(res['conceptscheme']['top_concepts'])
示例14: test_find_by_concept
def test_find_by_concept(self):
self.request.matchdict['scheme_id'] = 'TREES'
self.request.params = MultiDict()
self.request.params.add('ctype', 'concept')
self.request.params.add('_LOCALE_', 'nl')
self.request.skos_registry = self.regis
atramhasisview = AtramhasisView(self.request)
info = atramhasisview.search_result()
self.assertIsNotNone(info['concepts'])
concept = info['concepts'][0]
self.assertIsNotNone(concept)
self.assertEqual(info['scheme_id'], 'TREES')
示例15: test_not_found
def test_not_found(self):
request = self.request
request.matchdict['scheme_id'] = 'TREES'
request.matchdict['c_id'] = '666'
request.skos_registry = self.regis
error_raised = False
try:
atramhasisview = AtramhasisView(request)
atramhasisview.concept_view()
except ConceptNotFoundException as e:
error_raised = True
self.assertIsNotNone(e.__str__())
self.assertTrue(error_raised)