本文整理汇总了Python中mgi.tests.DataHandler.get_xsd2方法的典型用法代码示例。如果您正苦于以下问题:Python DataHandler.get_xsd2方法的具体用法?Python DataHandler.get_xsd2怎么用?Python DataHandler.get_xsd2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mgi.tests.DataHandler
的用法示例。
在下文中一共展示了DataHandler.get_xsd2方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RendererMainTestSuite
# 需要导入模块: from mgi.tests import DataHandler [as 别名]
# 或者: from mgi.tests.DataHandler import get_xsd2 [as 别名]
class RendererMainTestSuite(TestCase):
"""
"""
def setUp(self):
schema_data = join('utils', 'XSDParser', 'tests', 'data', 'parser')
self.schema_data_handler = DataHandler(schema_data)
self.request = HttpRequest()
engine = import_module('django.contrib.sessions.backends.db')
session_key = None
self.request.session = engine.SessionStore(session_key)
self.request.session['curate_edit'] = False # Data edition
form_data = FormData()
form_data.name = ''
form_data.user = ''
form_data.template = ''
form_data.save()
self.request.session['curateFormData'] = form_data.pk
def test_list_renderer(self):
main_directory = self.schema_data_handler.dirname
main_dir_len = len(main_directory) + 1
filepath_list = []
for root, dirs, files in walk(main_directory):
for filename in files:
file_ext = splitext(filename)
if file_ext[1] == '.xsd':
full_path = join(root, file_ext[0])
filepath_list.append(full_path[main_dir_len:])
report_content = []
error_count = 0
for filepath in filepath_list:
report_line = filepath
try:
xsd_data = self.schema_data_handler.get_xsd2(filepath)
self.request.session['xmlDocTree'] = etree.tostring(xsd_data)
root_pk = generate_form(self.request)
root_element = SchemaElement.objects.get(pk=root_pk)
renderer = ListRenderer(root_element)
renderer.render()
if len(renderer.warnings) != 0:
report_line += ',NOK,' + ','.join(renderer.warnings) + '\n'
error_count += 1
else: # No warnings yielded by the renderer
report_line += ',OK\n'
except Exception as e:
report_line += ',NOK,' + e.message + '\n'
error_count += 1
report_content.append(report_line)
with open(join(SITE_ROOT, 'full_tests_report.csv'), 'w') as report_file:
report_file.writelines(report_content)
self.assertEqual(error_count, 0)
def test_xml_renderer(self):
main_directory = self.schema_data_handler.dirname
main_dir_len = len(main_directory) + 1
filepath_list = []
for root, dirs, files in walk(main_directory):
for filename in files:
file_ext = splitext(filename)
if file_ext[1] == '.xsd':
full_path = join(root, file_ext[0])
filepath_list.append(full_path[main_dir_len:])
report_content = []
error_count = 0
for filepath in filepath_list:
report_line = filepath
try:
xsd_data = self.schema_data_handler.get_xsd2(filepath)
self.request.session['xmlDocTree'] = etree.tostring(xsd_data)
root_pk = generate_form(self.request)
root_element = SchemaElement.objects.get(pk=root_pk)
renderer = XmlRenderer(root_element)
renderer.render()
#.........这里部分代码省略.........