本文整理汇总了Python中pybossa.core.user_repo.get函数的典型用法代码示例。如果您正苦于以下问题:Python get函数的具体用法?Python get怎么用?Python get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_project_report_delete_existing_report
def test_project_report_delete_existing_report(self, mock_zip_exists):
"""Test project report is generated with deleting existing report zip"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export?type=project&format=csv' % project.short_name
res = self.app.get(url, follow_redirects=True)
开发者ID:PyBossa,项目名称:pybossa,代码行数:7,代码来源:test_project_report.py
示例2: newsletter_subscribe
def newsletter_subscribe():
"""
Register method for subscribing user to PyBossa newsletter.
Returns a Jinja2 template
"""
# Save that we've prompted the user to sign up in the newsletter
if newsletter.is_initialized() and current_user.is_authenticated():
next_url = request.args.get('next') or url_for('home.home')
user = user_repo.get(current_user.id)
if current_user.newsletter_prompted is False:
user.newsletter_prompted = True
user_repo.update(user)
if request.args.get('subscribe') == 'True':
newsletter.subscribe_user(user)
flash("You are subscribed to our newsletter!")
return redirect(next_url)
elif request.args.get('subscribe') == 'False':
return redirect(next_url)
else:
return render_template('account/newsletter.html',
title=gettext("Subscribe to our Newsletter"),
next=next_url)
else:
return abort(404)
开发者ID:bluetropic,项目名称:pybossa,代码行数:26,代码来源:account.py
示例3: test_get_inactive_users_returns_jobs
def test_get_inactive_users_returns_jobs(self):
"""Test JOB get inactive users returns a list of jobs."""
today = datetime.datetime.today()
old_date = today - datetime.timedelta(days=120)
date_str = old_date.strftime('%Y-%m-%dT%H:%M:%S.%f')
one_year = today - datetime.timedelta(days=365)
one_year_str = one_year.strftime('%Y-%m-%dT%H:%M:%S.%f')
user = UserFactory.create()
# 3 months old contribution
tr = TaskRunFactory.create(finish_time=date_str)
# 1 year old contribution
TaskRunFactory.create(finish_time=one_year_str)
# User with a contribution from a long time ago
TaskRunFactory.create(finish_time="2010-08-08T18:23:45.714110",
user=user)
# User with a recent contribution
TaskRunFactory.create(user=user)
user = user_repo.get(tr.user_id)
jobs_generator = get_inactive_users_jobs()
jobs = []
for job in jobs_generator:
jobs.append(job)
msg = "There should be one job."
print jobs
assert len(jobs) == 1, msg
job = jobs[0]
args = job['args'][0]
assert job['queue'] == 'quaterly', job['queue']
assert len(args['recipients']) == 1
assert args['recipients'][0] == user.email_addr, args['recipients'][0]
assert "UNSUBSCRIBE" in args['body']
assert "Update" in args['html']
开发者ID:chandra1b,项目名称:pybossa,代码行数:35,代码来源:test_engage_old_users.py
示例4: test_webhook_handler_admin
def test_webhook_handler_admin(self):
"""Test WEBHOOK view works for admin."""
# Admin
self.register()
self.signout()
# User
self.register(name="user", password="user")
owner = user_repo.get(2)
self.signout()
# Access as admin
self.signin()
project = ProjectFactory.create(owner=owner)
url = "/project/%s/webhook" % project.short_name
res = self.app.get(url)
assert res.status_code == 200, res.status_code
assert "Created" in res.data
assert "Payload" in res.data
url = "/project/%s/webhook?all=true" % project.short_name
res = self.app.get(url)
assert res.status_code == 200, res.status_code
assert "Created" in res.data
assert "Payload" in res.data
url = "/project/%s/webhook?failed=true" % project.short_name
res = self.app.get(url)
assert res.status_code == 200, res.status_code
assert "Created" in res.data
assert "Payload" in res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:27,代码来源:test_webhook.py
示例5: test_webhook_handler_all
def test_webhook_handler_all(self, q):
"""Test WEBHOOK requeing all works."""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user, webhook='server')
task = TaskFactory.create(project=project, n_answers=1)
AnonymousTaskRunFactory.create(project=project, task=task)
payload = self.payload(project, task)
wh1 = Webhook(project_id=project.id, payload=payload,
response='error', response_status_code=500)
webhook_repo.save(wh1)
wh2 = Webhook(project_id=project.id, payload=payload,
response='ok', response_status_code=200)
webhook_repo.save(wh2)
wh3 = Webhook(project_id=project.id, payload=payload,
response='ok', response_status_code=200)
webhook_repo.save(wh3)
whs = webhook_repo.filter_by(project_id=project.id)
url = "/project/%s/webhook?all=true" % (project.short_name)
res = self.app.get(url)
assert res.status_code == 200, res.status_code
calls = []
for w in whs:
calls.append(call(webhook, project.webhook,
w.payload, w.id, True))
q.assert_has_calls(calls)
开发者ID:PyBossa,项目名称:pybossa,代码行数:26,代码来源:test_webhook.py
示例6: test_project_report_no_zip_without_uploader
def test_project_report_no_zip_without_uploader(self, mock_no_up):
"""Test project report does not returns zip with no uploader instance """
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export?type=project&format=csv' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 500, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:8,代码来源:test_project_report.py
示例7: test_admin_owner_can_access_project_report_with_params
def test_admin_owner_can_access_project_report_with_params(self):
"""Test project report works when accessed with correct params"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export?type=project&format=csv' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 200, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:8,代码来源:test_project_report.py
示例8: test_project_report_with_bad_format_results_415
def test_project_report_with_bad_format_results_415(self):
"""Test project report accessed with bad format returns 415"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export?type=project&format=badfmt' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 415, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:8,代码来源:test_project_report.py
示例9: test_project_report_with_bad_params_results_404
def test_project_report_with_bad_params_results_404(self):
"""Test project report accessed with incorrect params returns 404"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export?badparam=badval' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 404, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:8,代码来源:test_project_report.py
示例10: test_admin_owner_can_access_project_report
def test_admin_owner_can_access_project_report(self):
"""Test admin can access project report"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = '/project/%s/projectreport/export' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 200, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:8,代码来源:test_project_report.py
示例11: test_stream_uri_private_auth
def test_stream_uri_private_auth(self):
"""Test stream URI private auth but not owner works."""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
self.signout()
self.register(fullname='Juan', name='juan', password='juana')
private_uri = '/project/%s/privatestream' % project.short_name
res = self.app.get(private_uri, follow_redirects=True)
assert res.status_code == 403, res.data
开发者ID:anukat2015,项目名称:pybossa,代码行数:10,代码来源:test_web_sse.py
示例12: test_webhook_handler_auth
def test_webhook_handler_auth(self):
"""Test WEBHOOK view works for authenticated not owner."""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
self.signout()
res = self.register(name="juan")
url = "/project/%s/webhook" % project.short_name
res = self.app.get(url)
assert res.status_code == 403, res.status_code
开发者ID:pkdevbox,项目名称:pybossa,代码行数:10,代码来源:test_webhook.py
示例13: test_stream_uri_private_owner_404
def test_stream_uri_private_owner_404(self):
"""Test stream URI private return 404 when SSE disabled
for owner works."""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
private_uri = '/project/%s/privatestream' % project.short_name
with patch.dict(self.flask_app.config, {'SSE': False}):
res = self.app.get(private_uri, follow_redirects=True)
assert res.status_code == 404
开发者ID:anukat2015,项目名称:pybossa,代码行数:10,代码来源:test_web_sse.py
示例14: test_stream_uri_private_owner
def test_stream_uri_private_owner(self, mock_response, mock_sse):
"""Test stream URI private owner works."""
mock_sse.return_value = self.fake_sse_response
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
private_uri = '/project/%s/privatestream' % project.short_name
self.app.get(private_uri, follow_redirects=True)
assert mock_sse.called
assert mock_sse.called_once_with(project.short_name, 'private')
开发者ID:anukat2015,项目名称:pybossa,代码行数:10,代码来源:test_web_sse.py
示例15: test_webhook_handler_owner
def test_webhook_handler_owner(self):
"""Test WEBHOOK view works for owner."""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
url = "/project/%s/webhook" % project.short_name
res = self.app.get(url)
assert res.status_code == 200, res.status_code
assert "Created" in res.data
assert "Payload" in res.data
开发者ID:pkdevbox,项目名称:pybossa,代码行数:10,代码来源:test_webhook.py
示例16: test_newsletter_subscribe
def test_newsletter_subscribe(self, newsletter):
"""Test NEWSLETTER view subcribe works."""
newsletter.is_initialized.return_value = True
newsletter.ask_user_to_subscribe.return_value = True
self.register()
res = self.app.get("/account/newsletter?subscribe=True", follow_redirects=True)
err_msg = "User should be subscribed"
user = user_repo.get(1)
assert "You are subscribed" in res.data, err_msg
assert newsletter.subscribe_user.called, err_msg
newsletter.subscribe_user.assert_called_with(user)
开发者ID:chandra1b,项目名称:pybossa,代码行数:11,代码来源:test_newsletter.py
示例17: test_nonadmin_noncoowner_access_project_report_results_403
def test_nonadmin_noncoowner_access_project_report_results_403(self):
"""Test nonadmin noncoowner accessing project report returns 403"""
self.register()
user = user_repo.get(1)
project = ProjectFactory.create(owner=user)
self.signout()
self.register(fullname='Juan', name='juan', password='juana')
self.signin(email="[email protected]", password='juana')
url = '/project/%s/projectreport/export' % project.short_name
res = self.app.get(url, follow_redirects=True)
assert res.status_code == 403, res.data
开发者ID:PyBossa,项目名称:pybossa,代码行数:11,代码来源:test_project_report.py
示例18: test_newsletter_subscribe_next
def test_newsletter_subscribe_next(self, newsletter):
"""Test NEWSLETTER view subscribe next works."""
newsletter.app = True
self.register()
next_url = '%2Faccount%2Fjohndoe%2Fupdate'
url ='/account/newsletter?subscribe=True&next=%s' % next_url
res = self.app.get(url, follow_redirects=True)
err_msg = "User should be subscribed"
user = user_repo.get(1)
assert "You are subscribed" in res.data, err_msg
assert newsletter.subscribe_user.called, err_msg
newsletter.subscribe_user.assert_called_with(user)
assert "Update" in res.data, res.data
开发者ID:alisheikh,项目名称:pybossa,代码行数:13,代码来源:test_newsletter.py
示例19: _handle_password_update
def _handle_password_update(user, password_form):
if password_form.validate_on_submit():
user = user_repo.get(user.id)
if user.check_password(password_form.current_password.data):
user.set_password(password_form.new_password.data)
user_repo.update(user)
flash(gettext('Yay, you changed your password succesfully!'),
'success')
else:
msg = gettext("Your current password doesn't match the "
"one in our records")
flash(msg, 'error')
else:
flash(gettext('Please correct the errors'), 'error')
开发者ID:bluetropic,项目名称:pybossa,代码行数:14,代码来源:account.py
示例20: test_get_non_contrib_users_jobs_with_users
def test_get_non_contrib_users_jobs_with_users(self):
"""Test JOB get with users returns empty list."""
TaskRunFactory.create()
user = user_repo.get(1)
jobs_generator = get_non_contributors_users_jobs()
jobs = []
for job in jobs_generator:
jobs.append(job)
msg = "There should not be any job."
assert len(jobs) == 1, msg
job = jobs[0]
args = job['args'][0]
assert args['recipients'][0] == user.email_addr, args['recipients'][1]
开发者ID:pkdevbox,项目名称:pybossa,代码行数:14,代码来源:test_engage_old_users.py
注:本文中的pybossa.core.user_repo.get函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论