本文整理汇总了Python中ckanext.dgu.testtools.create_test_data.DguCreateTestData类的典型用法代码示例。如果您正苦于以下问题:Python DguCreateTestData类的具体用法?Python DguCreateTestData怎么用?Python DguCreateTestData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DguCreateTestData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_class
def setup_class(cls):
model.repo.rebuild_db()
DguCreateTestData.create_dgu_test_data()
cls.publisher_controller = 'ckanext.dgu.controllers.publisher:PublisherController'
import ckanext.dgu.model.publisher_request as pr_model
pr_model.init_tables(model.meta.engine)
SmtpServerHarness.setup_class()
示例2: command
def command(self):
self._load_config()
self._setup_app()
# Now we can import
from ckan import plugins
from ckanext.dgu.testtools.create_test_data import DguCreateTestData
try:
plugins.load('synchronous_search') # so packages get indexed
except:
pass
self.log = logging.getLogger(__name__)
if self.args:
cmd = self.args[0]
else:
cmd = 'basic'
if cmd == 'basic':
DguCreateTestData.create_dgu_test_data()
elif cmd == 'users':
DguCreateTestData.create_dgu_test_users()
else:
print 'Command %s not recognized' % cmd
raise NotImplementedError
self.log.info('Created DGU test data successfully')
示例3: test_basic_dataset
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)
示例4: assert_create_or_edit
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,
)
示例5: setup_class
def setup_class(cls):
search.clear()
cls.tsi = TestSearchIndexer()
DguCreateTestData.create_dgu_test_data()
DguCreateTestData.create_arbitrary(
{"name": "latest", "notes": "<b>Latest</b> dataset.", "groups": ["national-health-service"]}
)
cls.tsi.index()
示例6: setup_class
def setup_class(cls):
search.clear()
cls.tsi = TestSearchIndexer()
DguCreateTestData.create_dgu_test_data()
DguCreateTestData.create_arbitrary({'name': 'latest',
'notes': '<b>Latest</b> dataset.',
'groups': ['national-health-service']})
cls.tsi.index()
示例7: test_1_edit_publisher
def test_1_edit_publisher(self):
# Load form
publisher_name = 'national-health-service'
group = model.Group.by_name(publisher_name)
offset = url_for('/publisher/edit/%s' % publisher_name)
res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER': 'nhsadmin'})
assert 'Edit Publisher' in res, res
form = res.forms[1]
# TODO assert_equal(form['title'].value, 'National Health Service')
assert_equal(form['name'].value, 'national-health-service')
assert_equal(form['description'].value, '')
# TODO assert_equal(form['parent'].value, 'dept-health')
assert_equal(form['contact-name'].value, '')
assert_equal(form['contact-email'].value, '[email protected]')
assert_equal(form['foi-name'].value, '')
assert_equal(form['foi-email'].value, '')
assert_equal(form['foi-web'].value, '')
assert_equal(form['category'].value, 'grouping')
assert_equal(form['abbreviation'].value, 'NHS')
# Make edit
publisher_name = 'new-name'
form['name'] = publisher_name
form['description'] = 'New description'
form['contact-name'] = 'Head of Comms'
form['contact-email'] = '[email protected]'
form['contact-phone'] = '01234 4567890'
form['foi-name'] = 'Head of FOI Comms'
form['foi-email'] = '[email protected]'
form['foi-phone'] = '0845 4567890'
form['foi-web'] = 'http://whatdotheyknow.com'
form['category'] = 'non-ministerial-department'
form['abbreviation'] = 'nhs'
res = form.submit('save', status=302, extra_environ={'REMOTE_USER': 'nhsadmin'})
# The return value is /organization, which routing then redirects to publisher
assert_equal(res.header_dict['Location'], 'http://localhost/organization/new-name')
# Check saved object
publisher = model.Group.by_name(publisher_name)
assert_equal(publisher.description, 'New description')
assert_equal(publisher.extras['contact-name'], 'Head of Comms')
assert_equal(publisher.extras['contact-email'], '[email protected]')
assert_equal(publisher.extras['contact-phone'], '01234 4567890')
assert_equal(publisher.extras['foi-name'], 'Head of FOI Comms')
assert_equal(publisher.extras['foi-email'], '[email protected]')
assert_equal(publisher.extras['foi-phone'], '0845 4567890')
assert_equal(publisher.extras['foi-web'], 'http://whatdotheyknow.com')
assert_equal(publisher.extras['category'], 'non-ministerial-department')
assert_equal(publisher.extras['abbreviation'], 'nhs')
# restore name for other tests
#model.repo.new_revision()
#publisher.name = 'national-health-service'
#model.repo.commit_and_remove()
model.repo.rebuild_db()
DguCreateTestData.create_dgu_test_data()
示例8: setup_class
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
DguCreateTestData.create_arbitrary({'name': 'latest',
'notes': '<b>Latest</b> dataset.',
'tags': ['tag1', 'tag2'],
'extras': {'key': 'value'},
'groups': ['national-health-service']})
cls._assert_revision_created()
model.Session.remove() # ensure last revision appears
示例9: test_5_appoint_editor
def test_5_appoint_editor(self):
publisher_name = 'national-health-service'
def check_related_publisher_properties():
group = model.Group.by_name(publisher_name)
# datasets
assert_equal(set([grp.name for grp in group.packages()]),
set([u'directgov-cota']))
# parents
child_groups = [grp.name for grp in model.Group.by_name('dept-health').get_children_groups('organization')]
assert publisher_name in child_groups, child_groups
check_related_publisher_properties()
DguCreateTestData.create_user(name='test_user')
assert model.User.by_name(u'test_user')
# Load form
group = model.Group.by_name(unicode(publisher_name))
offset = url_for('/publisher/users/%s' % publisher_name)
res = self.app.get(offset, status=200, extra_environ={'REMOTE_USER': 'nhsadmin'})
assert 'Edit User Permissions' in res, res
form = res.forms[1]
assert_equal(form['users__0__name'].value, 'nhsadmin')
assert_equal(form['users__0__capacity'].value, 'admin')
assert_equal(form['users__1__name'].value, 'nhseditor')
assert_equal(form['users__1__capacity'].value, 'editor')
assert_equal(form['users__2__name'].value, 'user_d101')
assert_equal(form['users__2__capacity'].value, 'editor')
assert_equal(form['users__3__name'].value, '')
# Edit the form
form['users__3__name'] = 'test_user'
res = form.submit('save', status=302, extra_environ={'REMOTE_USER': 'nhsadmin'})
assert_equal(res.header_dict['Location'], 'http://localhost/publisher/national-health-service')
# Check saved object
group = model.Group.by_name(unicode(publisher_name))
assert_equal(set([user.name for user in group.members_of_type(model.User, capacity='admin')]),
set(('nhsadmin',)))
assert_equal(set([user.name for user in group.members_of_type(model.User, capacity='editor')]),
set(('nhseditor', 'user_d101', 'test_user')))
check_related_publisher_properties()
示例10: setup_class
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
cls.publisher_controller = 'ckanext.dgu.controllers.publisher:PublisherController'
SmtpServerHarness.setup_class()
示例11: setup_class
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
示例12: setup_class
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
cls.inv_controller = 'ckanext.dgu.controllers.inventory:InventoryController'
示例13: setup_class
def setup_class(cls):
DguCreateTestData.create_dgu_test_data()
model.repo.new_revision()
示例14: setup_class
def setup_class(cls):
cls._form_client = _PackageFormClient()
DguCreateTestData.create_dgu_test_data()
示例15: setup_class
def setup_class(cls):
helpers.reset_db()
PylonsTestCase.setup_class()
DguCreateTestData.create_dgu_test_data()