本文整理汇总了Python中ckanext.dgu.testtools.create_test_data.DguCreateTestData.form_package方法的典型用法代码示例。如果您正苦于以下问题:Python DguCreateTestData.form_package方法的具体用法?Python DguCreateTestData.form_package怎么用?Python DguCreateTestData.form_package使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ckanext.dgu.testtools.create_test_data.DguCreateTestData
的用法示例。
在下文中一共展示了DguCreateTestData.form_package方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: assert_create_or_edit
# 需要导入模块: from ckanext.dgu.testtools.create_test_data import DguCreateTestData [as 别名]
# 或者: from ckanext.dgu.testtools.create_test_data.DguCreateTestData import form_package [as 别名]
def assert_create_or_edit(self, create_or_edit, user_name, allowed=True):
if create_or_edit == "create":
package_data = _EXAMPLE_TIMESERIES_DATA.copy()
package_data["name"] = "tstcreate" + user_name
package_data["groups__0__name"] = "national-health-service"
package_name = package_data["name"]
package_id = None
else:
package_data = {}
package_id = DguCreateTestData.form_package().id
package_name = DguCreateTestData.form_package().name
response = self._form_client.post_form(
package_data, id=package_id, user_name=user_name, use_sysadmin_to_get_form=True, abort_on_bad_status=False
)
redirect = response.header_dict.get("Location", "")
dataset_read_path = "/dataset/%s" % package_name
if allowed:
# 200 means there are form errors
assert response.status != 200, response.body
# 302 is what is wanted - a redirect to the package read page
assert_equal(response.status, 302)
assert dataset_read_path in redirect, redirect
else:
assert_equal(response.status, 401)
assert dataset_read_path not in redirect, redirect
# also assert that you couldn't get the form in the first place
assert_raises(
paste.fixture.AppError,
self._form_client.post_form,
package_data,
user_name=user_name,
use_sysadmin_to_get_form=False,
abort_on_bad_status=False,
)
示例2: setup_class
# 需要导入模块: from ckanext.dgu.testtools.create_test_data import DguCreateTestData [as 别名]
# 或者: from ckanext.dgu.testtools.create_test_data.DguCreateTestData import form_package [as 别名]
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
cls.pkg_name = DguCreateTestData.form_package().name
cls.pkg_id = DguCreateTestData.form_package().id
cls.extra_environ_editor = {"Authorization": str(model.User.by_name("nhseditor").apikey)}
cls.extra_environ_admin = {"Authorization": str(model.User.by_name("nhsadmin").apikey)}
cls.extra_environ_sysadmin = {"Authorization": str(model.User.by_name("sysadmin").apikey)}
cls.context = {"model": model, "session": model.Session, "user": ""}
示例3: setup_class
# 需要导入模块: from ckanext.dgu.testtools.create_test_data import DguCreateTestData [as 别名]
# 或者: from ckanext.dgu.testtools.create_test_data.DguCreateTestData import form_package [as 别名]
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
cls.pkg_name = DguCreateTestData.form_package().name
cls.pkg_id = DguCreateTestData.form_package().id
cls.extra_environ_editor = {
'Authorization': str(model.User.by_name('nhseditor').apikey)}
cls.extra_environ_admin = {
'Authorization': str(model.User.by_name('nhsadmin').apikey)}
cls.extra_environ_sysadmin = {
'Authorization': str(model.User.by_name('sysadmin').apikey)}
cls.context = {'model': model, 'session': model.Session,
'user': ''}
示例4: test_basic_dataset
# 需要导入模块: from ckanext.dgu.testtools.create_test_data import DguCreateTestData [as 别名]
# 或者: from ckanext.dgu.testtools.create_test_data.DguCreateTestData import form_package [as 别名]
def test_basic_dataset(self):
DguCreateTestData.create_dgu_test_data()
pkg_name = DguCreateTestData.form_package().name
context = {"model": model, "session": model.Session, "user": "nhseditor"}
pkg = get_action("package_show")(context, {"id": pkg_name})
get_action("package_update")(context, pkg)