本文整理汇总了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)
示例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))
示例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))