本文整理汇总了Python中ckan.tests.legacy.CreateTestData类的典型用法代码示例。如果您正苦于以下问题:Python CreateTestData类的具体用法?Python CreateTestData怎么用?Python CreateTestData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreateTestData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_perform_reset_user_password_link_key_missing
def test_perform_reset_user_password_link_key_missing(self):
CreateTestData.create_user(name='jack', password='test1')
user = model.User.by_name(u'jack')
offset = url_for(controller='user',
action='perform_reset',
id=user.id) # not, no key specified
res = self.app.get(offset, status=403) # error
示例2: test_perform_reset_user_password_link_key_incorrect
def test_perform_reset_user_password_link_key_incorrect(self):
CreateTestData.create_user(name='jack', password='test1')
# Make up a key - i.e. trying to hack this
user = model.User.by_name(u'jack')
offset = url_for(controller='user',
action='perform_reset',
id=user.id,
key='randomness') # i.e. incorrect
res = self.app.get(offset, status=403) # error
示例3: setup_class
def setup_class(cls):
CreateTestData.create()
cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)
joeadmin = ckan.model.User.get("joeadmin")
cls.joeadmin = {"id": joeadmin.id, "apikey": joeadmin.apikey}
annafan = ckan.model.User.get("annafan")
cls.annafan = {"id": annafan.id, "apikey": annafan.apikey}
testsysadmin = ckan.model.User.get("testsysadmin")
cls.testsysadmin = {"id": testsysadmin.id, "apikey": testsysadmin.apikey}
cls.new_user = cls.user_create()
示例4: setup_class
def setup_class(cls):
model.Session.remove()
setup_test_search_index()
CreateTestData.create_search_test_data()
# now remove a tag so we can test search with deleted tags
model.repo.new_revision()
gils = model.Package.by_name(u'gils')
# an existing tag used only by gils
cls.tagname = u'registry'
idx = [t.name for t in gils.get_tags()].index(cls.tagname)
gils.remove_tag(gils.get_tags()[idx])
model.repo.commit_and_remove()
示例5: setup_class
def setup_class(cls):
cls._original_config = config.copy()
for key in config.keys():
if key.startswith('ofs'):
del config[key]
config['ofs.impl'] = 'pairtree'
config['ckan.storage.bucket'] = 'ckantest'
config['ofs.storage_dir'] = '/tmp/ckan-test-ckanext-storage'
create_pairtree_marker( config['ofs.storage_dir'] )
wsgiapp = make_app(config['global_conf'], **config)
cls.app = paste.fixture.TestApp(wsgiapp)
CreateTestData.create_test_user()
示例6: setup_class
def setup_class(cls):
CreateTestData.create()
cls.app = paste.fixture.TestApp(pylons.test.pylonsapp)
joeadmin = ckan.model.User.get('joeadmin')
cls.joeadmin = {
'id': joeadmin.id,
'apikey': joeadmin.apikey
}
annafan = ckan.model.User.get('annafan')
cls.annafan = {
'id': annafan.id,
'apikey': annafan.apikey
}
testsysadmin = ckan.model.User.get('testsysadmin')
cls.testsysadmin = {
'id': testsysadmin.id,
'apikey': testsysadmin.apikey
}
cls.new_user = cls.user_create()
示例7: test_user_delete_redirects_to_user_index
def test_user_delete_redirects_to_user_index(self):
user = CreateTestData.create_user('a_user')
url = url_for(controller='user', action='delete', id=user.id)
extra_environ = {'REMOTE_USER': 'testsysadmin'}
redirect_url = url_for(controller='user', action='index',
qualified=True)
res = self.app.get(url, status=302, extra_environ=extra_environ)
assert user.is_deleted(), user
assert res.header('Location').startswith(redirect_url), res.header('Location')
示例8: setup_class
def setup_class(cls):
ckan.model.repo.rebuild_db()
ckan.lib.search.clear_all()
CreateTestData.create()
cls.app = helpers._get_test_app()
joeadmin = ckan.model.User.get('joeadmin')
cls.joeadmin = {
'id': joeadmin.id,
'apikey': joeadmin.apikey
}
annafan = ckan.model.User.get('annafan')
cls.annafan = {
'id': annafan.id,
'apikey': annafan.apikey
}
testsysadmin = ckan.model.User.get('testsysadmin')
cls.testsysadmin = {
'id': testsysadmin.id,
'apikey': testsysadmin.apikey
}
cls.new_user = cls.user_create()
示例9: setup_class
def setup_class(cls):
smtp_server = config.get('smtp.test_server')
if smtp_server:
host, port = smtp_server.split(':')
port = int(port) + int(str(hashlib.md5(cls.__name__).hexdigest())[0], 16)
config['smtp.test_server'] = '%s:%s' % (host, port)
SmtpServerHarness.setup_class()
CreateTestData.create()
# make 3 changes, authored by annafan
for i in range(3):
rev = model.repo.new_revision()
pkg = model.Package.by_name(u'annakarenina')
pkg.notes = u'Changed notes %i' % i
rev.author = u'annafan'
model.repo.commit_and_remove()
CreateTestData.create_user('unfinisher', about='<a href="http://unfinished.tag')
CreateTestData.create_user('uncloser', about='<a href="http://unclosed.tag">')
CreateTestData.create_user('spammer', about=u'<a href="http://mysite">mysite</a> <a href=\u201dhttp://test2\u201d>test2</a>')
CreateTestData.create_user('spammer2', about=u'<a href="http://spamsite1.com\u201d>spamsite1</a>\r\n<a href="http://www.spamsite2.com\u201d>spamsite2</a>\r\n')
示例10: setup_class
def setup_class(cls):
setup_test_search_index()
# Force a garbage collection to trigger issue #695
import gc
gc.collect()
CreateTestData.create()
cls.new_pkg_dict = {
'name': 'council-owned-litter-bins',
'notes': 'Location of Council owned litter bins within Borough.',
'resources': [{'description': 'Resource locator',
'format': 'Unverified',
'url': 'http://www.barrowbc.gov.uk'}],
'tags': ['Utility and governmental services'],
'title': 'Council Owned Litter Bins',
'extras': {
'INSPIRE': 'True',
'bbox-east-long': '-3.12442',
'bbox-north-lat': '54.218407',
'bbox-south-lat': '54.039634',
'bbox-west-long': '-3.32485',
'constraint': 'conditions unknown; (e) intellectual property rights;',
'dataset-reference-date': json.dumps(
[{'type': 'creation',
'value': '2008-10-10'},
{'type': 'revision',
'value': '2009-10-08'}]),
'guid': '00a743bf-cca4-4c19-a8e5-e64f7edbcadd',
'metadata-date': '2009-10-16',
'metadata-language': 'eng',
'published_by': 0,
'resource-type': 'dataset',
'spatial-reference-system': 'test-spatial',
'temporal_coverage-from': '1977-03-10T11:45:30',
'temporal_coverage-to': '2005-01-15T09:10:00'
}
}
示例11: setup_class
def setup_class(self):
model.Session.remove()
CreateTestData.create()
self.name = u'revisiontest'
# create pkg
self.descriptions = [u'Written by Puccini', u'Written by Rossini', u'Not written at all', u'Written again', u'Written off']
rev = model.repo.new_revision()
self.grp = model.Group(name=self.name)
model.Session.add(self.grp)
self.grp.description = self.descriptions[0]
self.grp.extras['mykey'] = self.descriptions[0]
model.repo.commit_and_remove()
# edit pkg
for i in range(5)[1:]:
rev = model.repo.new_revision()
grp = model.Group.by_name(self.name)
grp.description = self.descriptions[i]
grp.extras['mykey'] = self.descriptions[i]
model.repo.commit_and_remove()
self.grp = model.Group.by_name(self.name)
示例12: test_perform_reset_doesnt_activate_deleted_user
def test_perform_reset_doesnt_activate_deleted_user(self):
password = 'password'
params = { 'password1': password, 'password2': password }
user = CreateTestData.create_user(name='deleted_user',
email='[email protected]')
user.delete()
create_reset_key(user)
assert user.is_deleted(), user.state
offset = url_for(controller='user',
action='perform_reset',
id=user.id,
key=user.reset_key)
res = self.app.post(offset, params=params, status=403)
user = model.User.get(user.id)
assert user.is_deleted(), user
示例13: setup_class
def setup_class(cls):
# setup test data including testsysadmin user
CreateTestData.create()
示例14: setup_class
def setup_class(self):
model.repo.rebuild_db()
CreateTestData.create()
示例15: _create_package
def _create_package(self, package=None):
CreateTestData.create_arbitrary(self.new_pkg_dict)
return model.Package.by_name(self.new_pkg_dict['name'])