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


Python TestBase._publish_xls_file方法代码示例

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


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

示例1: _publish_transportation_id_string_starts_with_number_form

# 需要导入模块: from test_base import TestBase [as 别名]
# 或者: from test_base.TestBase import _publish_xls_file [as 别名]
    def _publish_transportation_id_string_starts_with_number_form(self):
        xls_path = os.path.join(self.this_directory, "fixtures",
                                "transportation",
                                "transportation.id_starts_with_num.xls")
        count = XForm.objects.count()
        TestBase._publish_xls_file(self, xls_path)

        self.assertEqual(XForm.objects.count(), count + 1)
        self.xform = XForm.objects.all().reverse()[0]
开发者ID:Azique,项目名称:kobocat,代码行数:11,代码来源:test_form_gallery.py

示例2: test_uuid_injection_in_cascading_select

# 需要导入模块: from test_base import TestBase [as 别名]
# 或者: from test_base.TestBase import _publish_xls_file [as 别名]
    def test_uuid_injection_in_cascading_select(self):
        """Test that the uuid is injected in the right instance node for
        forms with a cascading select"""
        pre_count = XForm.objects.count()
        xls_path = os.path.join(
            self.this_directory, "fixtures", "cascading_selects",
            "new_cascading_select.xls")
        file_name, file_ext = os.path.splitext(os.path.split(xls_path)[1])
        TestBase._publish_xls_file(self, xls_path)
        post_count = XForm.objects.count()
        self.assertEqual(post_count, pre_count + 1)
        xform = XForm.objects.latest('date_created')

        # check that the uuid is within the main instance/
        # the one without an id attribute
        xml = clean_and_parse_xml(xform.xml)

        # check for instance nodes that are direct children of the model node
        model_node = xml.getElementsByTagName("model")[0]
        instance_nodes = [node for node in model_node.childNodes if
                          node.nodeType == Node.ELEMENT_NODE and
                          node.tagName.lower() == "instance" and
                          not node.hasAttribute("id")]
        self.assertEqual(len(instance_nodes), 1)
        instance_node = instance_nodes[0]

        # get the first element whose id attribute is equal to our form's
        # id_string
        form_nodes = [node for node in instance_node.childNodes if
                      node.nodeType == Node.ELEMENT_NODE and
                      node.getAttribute("id") == xform.id_string]
        form_node = form_nodes[0]

        # find the formhub node that has a uuid child node
        formhub_nodes = form_node.getElementsByTagName("formhub")
        self.assertEqual(len(formhub_nodes), 1)
        uuid_nodes = formhub_nodes[0].getElementsByTagName("uuid")
        self.assertEqual(len(uuid_nodes), 1)

        # check for the calculate bind
        calculate_bind_nodes = [node for node in model_node.childNodes if
                                node.nodeType == Node.ELEMENT_NODE and
                                node.tagName == "bind" and
                                node.getAttribute("nodeset") ==
                                "/%s/formhub/uuid" % file_name]
        self.assertEqual(len(calculate_bind_nodes), 1)
        calculate_bind_node = calculate_bind_nodes[0]
        self.assertEqual(
            calculate_bind_node.getAttribute("calculate"), "'%s'" % xform.uuid)
开发者ID:MichaelRoethlin,项目名称:onadata,代码行数:51,代码来源:test_process.py

示例3: _publish_file

# 需要导入模块: from test_base import TestBase [as 别名]
# 或者: from test_base.TestBase import _publish_xls_file [as 别名]
 def _publish_file(self, xls_path, strict=True):
     """
     Returns False if not strict and publish fails
     """
     pre_count = XForm.objects.count()
     TestBase._publish_xls_file(self, xls_path)
     # make sure publishing the survey worked
     if XForm.objects.count() != pre_count + 1:
         # print file location
         print '\nPublish Failure for file: %s' % xls_path
         if strict:
             self.assertEqual(XForm.objects.count(), pre_count + 1)
         else:
             return False
     self.xform = list(XForm.objects.all())[-1]
     return True
开发者ID:MichaelRoethlin,项目名称:onadata,代码行数:18,代码来源:test_process.py

示例4: test_publish_bad_xls_with_unicode_in_error

# 需要导入模块: from test_base import TestBase [as 别名]
# 或者: from test_base.TestBase import _publish_xls_file [as 别名]
 def test_publish_bad_xls_with_unicode_in_error(self):
     """
     Check that publishing a bad xls where the error has a unicode character
     returns a 200, thus showing a readable error to the user
     """
     self._create_user_and_login()
     path = os.path.join(
         self.this_directory, 'fixtures',
         'form_with_unicode_in_relevant_column.xlsx')
     response = TestBase._publish_xls_file(self, path)
     # make sure we get a 200 response
     self.assertEqual(response.status_code, 200)
开发者ID:cagulas,项目名称:onadata,代码行数:14,代码来源:test_process.py

示例5: _publish_survey

# 需要导入模块: from test_base import TestBase [as 别名]
# 或者: from test_base.TestBase import _publish_xls_file [as 别名]
 def _publish_survey(self):
     self.this_directory = os.path.dirname(__file__)
     xls_path = os.path.join(
         self.this_directory, "fixtures", "gps", "gps.xls")
     TestBase._publish_xls_file(self, xls_path)
开发者ID:199212151746,项目名称:onadata,代码行数:7,代码来源:test_gps.py


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