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


Python MetaData.textit方法代码示例

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


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

示例1: test_textit_service

# 需要导入模块: from onadata.apps.main.models import MetaData [as 别名]
# 或者: from onadata.apps.main.models.MetaData import textit [as 别名]
    def test_textit_service(self, mock_http):
        service_url = "https://textit.io/api/v1/runs.json"
        service_name = "textit"

        self._add_rest_service(service_url, service_name)

        # add metadata
        api_token = "asdaasda"
        flow_uuid = "getvdgdfd"
        default_contact = "sadlsdfskjdfds"

        MetaData.textit(
            self.xform, data_value="{}|{}|{}".format(api_token,
                                                     flow_uuid,
                                                     default_contact))

        xml_submission = os.path.join(self.this_directory,
                                      u'fixtures',
                                      u'dhisform_submission1.xml')

        self.assertFalse(mock_http.called)
        self._make_submission(xml_submission)
        self.assertTrue(mock_http.called)
        self.assertEquals(mock_http.call_count, 1)
开发者ID:MichaelRoethlin,项目名称:onadata,代码行数:26,代码来源:test_restservice.py

示例2: send

# 需要导入模块: from onadata.apps.main.models import MetaData [as 别名]
# 或者: from onadata.apps.main.models.MetaData import textit [as 别名]
    def send(self, url, submission_instance):
        """
        Sends the submission to the configured rest service
        :param url:
        :param submission_instance:
        :return:
        """
        extra_data = self.clean_keys_of_slashes(submission_instance.json)

        data_value = MetaData.textit(submission_instance.xform)

        if data_value:
            token, flow, contacts = data_value.split(METADATA_SEPARATOR)
            post_data = {
                "extra": extra_data,
                "flow": flow,
                "contacts": contacts.split(',')
            }
            headers = {"Content-Type": "application/json",
                       "Authorization": "Token {}".format(token)}

            requests.post(url, headers=headers, data=json.dumps(post_data))
开发者ID:onaio,项目名称:onadata,代码行数:24,代码来源:textit.py

示例3: send

# 需要导入模块: from onadata.apps.main.models import MetaData [as 别名]
# 或者: from onadata.apps.main.models.MetaData import textit [as 别名]
    def send(self, url, parsed_instance):
        """
        Sends the submission to the configured rest service
        :param url:
        :param parsed_instance:
        :return:
        """
        extra_data = self.clean_keys_of_slashes(parsed_instance.instance.json)

        meta = MetaData.textit(parsed_instance.instance.xform)

        token, flow_uuid, contacts = meta.data_value.split(METADATA_SEPARATOR)
        post_data = {
            "extra": extra_data,
            "flow_uuid": flow_uuid,
            "contacts": contacts
        }
        headers = {"Content-Type": "application/json",
                   "Authorization": "Token {}".format(token)}
        http = httplib2.Http()

        resp, content = http.request(uri=url, method='POST',
                                     headers=headers,
                                     body=json.dumps(post_data))
开发者ID:MichaelRoethlin,项目名称:onadata,代码行数:26,代码来源:textit.py


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