本文整理汇总了Python中mediagoblin.tests.tools.fixture_add_user函数的典型用法代码示例。如果您正苦于以下问题:Python fixture_add_user函数的具体用法?Python fixture_add_user怎么用?Python fixture_add_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fixture_add_user函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _setup
def _setup(self, test_app):
self.test_app = test_app
fixture_add_user(u'allie',
privileges=[u'reporter',u'active'])
fixture_add_user(u'natalie',
privileges=[u'active', u'moderator'])
开发者ID:campadrenalin,项目名称:mediagoblin,代码行数:7,代码来源:test_reporting.py
示例2: test_search_link_present
def test_search_link_present(test_app):
"""Test the search form is present if search is 'users only', and
a user is logged in."""
fixture_add_user(privileges=['active', 'uploader', 'commenter'])
test_app.post('/auth/login/', {'username': 'chris',
'password': 'toast'})
response = test_app.get('/')
assert '/search/' in [form.action for form in itervalues(response.forms)]
开发者ID:tofay,项目名称:mediagoblin-indexedsearch,代码行数:8,代码来源:test_search_link.py
示例3: setup
def setup(self, test_app):
self.test_app = test_app
# TODO: Possibly abstract into a decorator like:
# @as_authenticated_user('chris')
fixture_add_user(privileges=[u'active',u'uploader', u'commenter'])
self.login()
开发者ID:piratas,项目名称:biblioteca,代码行数:8,代码来源:test_submission.py
示例4: test_user_deletes_other_comments
def test_user_deletes_other_comments(test_app):
user_a = fixture_add_user(u"chris_a")
user_b = fixture_add_user(u"chris_b")
media_a = fixture_media_entry(uploader=user_a.id, save=False,
expunge=False, fake_upload=False)
media_b = fixture_media_entry(uploader=user_b.id, save=False,
expunge=False, fake_upload=False)
Session.add(media_a)
Session.add(media_b)
Session.flush()
# Create all 4 possible comments:
for u in (user_a, user_b):
for m in (media_a, media_b):
cmt = TextComment()
cmt.actor = u.id
cmt.content = u"Some Comment"
Session.add(cmt)
# think i need this to get the command ID
Session.flush()
link = Comment()
link.target = m
link.comment = cmt
Session.add(link)
Session.flush()
usr_cnt1 = User.query.count()
med_cnt1 = MediaEntry.query.count()
cmt_cnt1 = Comment.query.count()
User.query.get(user_a.id).delete(commit=False)
usr_cnt2 = User.query.count()
med_cnt2 = MediaEntry.query.count()
cmt_cnt2 = Comment.query.count()
# One user deleted
assert usr_cnt2 == usr_cnt1 - 1
# One media gone
assert med_cnt2 == med_cnt1 - 1
# Three of four comments gone.
assert cmt_cnt2 == cmt_cnt1 - 3
User.query.get(user_b.id).delete()
usr_cnt2 = User.query.count()
med_cnt2 = MediaEntry.query.count()
cmt_cnt2 = Comment.query.count()
# All users gone
assert usr_cnt2 == usr_cnt1 - 2
# All media gone
assert med_cnt2 == med_cnt1 - 2
# All comments gone
assert cmt_cnt2 == cmt_cnt1 - 4
开发者ID:ausbin,项目名称:mediagoblin,代码行数:58,代码来源:test_misc.py
示例5: _setup
def _setup(self):
fixture_add_user(u'natalie',
privileges=[u'admin',u'moderator',u'active'])
fixture_add_user(u'aeva',
privileges=[u'moderator',u'active'])
self.natalie_user = User.query.filter(
User.username==u'natalie').first()
self.aeva_user = User.query.filter(
User.username==u'aeva').first()
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:9,代码来源:test_modelmethods.py
示例6: setup
def setup(self, test_app):
self.test_app = test_app
if self.usernames is None:
msg = ('The usernames attribute should be overridden '
'in the subclass')
raise pytest.skip(msg)
for username, options in self.usernames:
fixture_add_user(username, **options)
开发者ID:ausbin,项目名称:mediagoblin,代码行数:9,代码来源:__init__.py
示例7: setup
def setup(self, test_app):
self.test_app = test_app
self.db = mg_globals.database
self.user = fixture_add_user(privileges=[u'active', u'uploader', u'commenter'])
self.other_user = fixture_add_user(
username="otheruser",
privileges=[u'active', u'uploader', u'commenter']
)
开发者ID:incorpusyehtee,项目名称:mediagoblin,代码行数:9,代码来源:test_api.py
示例8: test_user_deletes_other_comments
def test_user_deletes_other_comments(test_app):
user_a = fixture_add_user(u"chris_a")
user_b = fixture_add_user(u"chris_b")
media_a = fixture_media_entry(uploader=user_a.id, save=False,
expunge=False, fake_upload=False)
media_b = fixture_media_entry(uploader=user_b.id, save=False,
expunge=False, fake_upload=False)
Session.add(media_a)
Session.add(media_b)
Session.flush()
# Create all 4 possible comments:
for u_id in (user_a.id, user_b.id):
for m_id in (media_a.id, media_b.id):
cmt = MediaComment()
cmt.media_entry = m_id
cmt.author = u_id
cmt.content = u"Some Comment"
Session.add(cmt)
Session.flush()
usr_cnt1 = User.query.count()
med_cnt1 = MediaEntry.query.count()
cmt_cnt1 = MediaComment.query.count()
User.query.get(user_a.id).delete(commit=False)
usr_cnt2 = User.query.count()
med_cnt2 = MediaEntry.query.count()
cmt_cnt2 = MediaComment.query.count()
# One user deleted
assert usr_cnt2 == usr_cnt1 - 1
# One media gone
assert med_cnt2 == med_cnt1 - 1
# Three of four comments gone.
assert cmt_cnt2 == cmt_cnt1 - 3
User.query.get(user_b.id).delete()
usr_cnt2 = User.query.count()
med_cnt2 = MediaEntry.query.count()
cmt_cnt2 = MediaComment.query.count()
# All users gone
assert usr_cnt2 == usr_cnt1 - 2
# All media gone
assert med_cnt2 == med_cnt1 - 2
# All comments gone
assert cmt_cnt2 == cmt_cnt1 - 4
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:52,代码来源:test_misc.py
示例9: test_change_bio_url
def test_change_bio_url(self, test_app):
"""Test changing bio and URL"""
self.login(test_app)
# Test if legacy profile editing URL redirects correctly
res = test_app.post(
'/edit/profile/', {
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'}, expect_errors=True)
# Should redirect to /u/chris/edit/
assert res.status_int == 302
assert res.headers['Location'].endswith("/u/chris/edit/")
res = test_app.post(
'/u/chris/edit/', {
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'})
test_user = User.query.filter_by(username=u'chris').first()
assert test_user.bio == u'I love toast!'
assert test_user.url == u'http://dustycloud.org/'
# change a different user than the logged in (should fail with 403)
fixture_add_user(username=u"foo",
privileges=[u'active'])
res = test_app.post(
'/u/foo/edit/', {
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'}, expect_errors=True)
assert res.status_int == 403
# test changing the bio and the URL inproperly
too_long_bio = 150 * 'T' + 150 * 'o' + 150 * 'a' + 150 * 's' + 150* 't'
test_app.post(
'/u/chris/edit/', {
# more than 500 characters
'bio': too_long_bio,
'url': 'this-is-no-url'})
# Check form errors
context = template.TEMPLATE_TEST_CONTEXT[
'mediagoblin/edit/edit_profile.html']
form = context['form']
assert form.bio.errors == [
u'Field must be between 0 and 500 characters long.']
assert form.url.errors == [
u'This address contains errors']
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:50,代码来源:test_edit.py
示例10: test_change_password
def test_change_password(test_app):
"""Test changing password correctly and incorrectly"""
test_user = fixture_add_user(password=u'toast')
test_app.post(
'/auth/login/', {
'username': u'chris',
'password': u'toast'})
# test that the password can be changed
res = test_app.post(
'/edit/password/', {
'old_password': 'toast',
'new_password': '123456',
})
res.follow()
# Did we redirect to the correct page?
assert urlparse.urlsplit(res.location)[2] == '/edit/account/'
# test_user has to be fetched again in order to have the current values
test_user = User.query.filter_by(username=u'chris').first()
assert auth_tools.bcrypt_check_password('123456', test_user.pw_hash)
# test that the password cannot be changed if the given
# old_password is wrong
template.clear_test_template_context()
test_app.post(
'/edit/password/', {
'old_password': 'toast',
'new_password': '098765',
})
test_user = User.query.filter_by(username=u'chris').first()
assert not auth_tools.bcrypt_check_password('098765', test_user.pw_hash)
开发者ID:commonsmachinery,项目名称:mediagoblin,代码行数:35,代码来源:test_basic_auth.py
示例11: test_garbage_collection_task
def test_garbage_collection_task(test_app):
""" Test old media entry are removed by GC task """
user = fixture_add_user()
# Create a media entry that's unprocessed and over an hour old.
entry_id = 72
now = datetime.datetime.now(pytz.UTC)
file_data = FileStorage(
stream=open(GOOD_JPG, "rb"),
filename="mah_test.jpg",
content_type="image/jpeg"
)
# Find media manager
media_type, media_manager = sniff_media(file_data, "mah_test.jpg")
entry = new_upload_entry(user)
entry.id = entry_id
entry.title = "Mah Image"
entry.slug = "slugy-slug-slug"
entry.media_type = 'image'
entry.created = now - datetime.timedelta(days=2)
entry.save()
# Validate the model exists
assert MediaEntry.query.filter_by(id=entry_id).first() is not None
# Call the garbage collection task
collect_garbage()
# Now validate the image has been deleted
assert MediaEntry.query.filter_by(id=entry_id).first() is None
开发者ID:goblinrefuge,项目名称:goblinrefuge-mediagoblin,代码行数:31,代码来源:test_misc.py
示例12: change_bio_url
def change_bio_url(test_app):
"""Test changing bio and URL"""
# set up new user
test_user = fixture_add_user()
# test changing the bio and the URL properly
test_app.post(
'/edit/profile/', {
'bio': u'I love toast!',
'url': u'http://dustycloud.org/'})
test_user = mg_globals.database.User.one({'username': u'chris'})
assert test_user.bio == u'I love toast!'
assert test_user.url == u'http://dustycloud.org/'
# test changing the bio and the URL inproperly
too_long_bio = 150 * 'T' + 150 * 'o' + 150 * 'a' + 150 * 's' + 150* 't'
test_app.post(
'/edit/profile/', {
# more than 500 characters
'bio': too_long_bio,
'url': 'this-is-no-url'})
test_user = mg_globals.database.User.one({'username': u'chris'})
context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/edit/edit_profile.html']
form = context['edit_profile_form']
assert form.bio.errors == [u'Field must be between 0 and 500 characters long.']
assert form.url.errors == [u'Improperly formed URL']
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:32,代码来源:test_edit.py
示例13: test_comments_removed_when_graveyarded
def test_comments_removed_when_graveyarded(test_app):
""" Checks comments which are tombstones are removed from collection """
user = fixture_add_user()
media = fixture_media_entry(
uploader=user.id,
expunge=False,
fake_upload=False
)
# Add the TextComment
comment = TextComment()
comment.actor = user.id
comment.content = u"This is a comment that will be deleted."
comment.save()
# Add a link for the comment
link = Comment()
link.target = media
link.comment = comment
link.save()
# First double check it's there and all is well...
assert Comment.query.filter_by(target_id=link.target_id).first() is not None
# Now delete the comment.
comment.delete()
# Verify this also deleted the Comment link, ergo there is no comment left.
assert Comment.query.filter_by(target_id=link.target_id).first() is None
开发者ID:ausbin,项目名称:mediagoblin,代码行数:29,代码来源:test_misc.py
示例14: _test_delete
def _test_delete(self, test_user):
# Delete openid from user
# Create another user to test deleting OpenID that doesn't belong to them
new_user = fixture_add_user(username="newman")
openid = OpenIDUserURL()
openid.openid_url = "http://realfake.myopenid.com/"
openid.user_id = new_user.id
openid.save()
# Try and delete OpenID url that isn't the users
template.clear_test_template_context()
res = openid_plugin_app.post("/edit/openid/delete/", {"openid": "http://realfake.myopenid.com/"})
context = template.TEMPLATE_TEST_CONTEXT["mediagoblin/plugins/openid/delete.html"]
form = context["form"]
assert form.openid.errors == [u"That OpenID is not registered to this account."]
# Delete OpenID
# Kind of weird to POST to delete/finish
template.clear_test_template_context()
res = openid_plugin_app.post("/edit/openid/delete/finish/", {"openid": u"http://add.myopenid.com"})
res.follow()
# Correct place?
assert urlparse.urlsplit(res.location)[2] == "/edit/account/"
assert "mediagoblin/edit/edit_account.html" in template.TEMPLATE_TEST_CONTEXT
# OpenID deleted?
new_openid = mg_globals.database.OpenIDUserURL.query.filter_by(
openid_url=u"http://add.myopenid.com"
).first()
assert not new_openid
开发者ID:aurelienmaury,项目名称:JoshuaGoblin,代码行数:31,代码来源:test_openid.py
示例15: setup
def setup(self, test_app):
# set up new user
self.user_password = u'toast'
self.user = fixture_add_user(
password = self.user_password,
privileges=[u'active',u'admin']
)
self.test_app = test_app
开发者ID:ausbin,项目名称:mediagoblin,代码行数:8,代码来源:test_edit.py
示例16: setUp
def setUp(self):
self.app = get_test_app()
self.db = mg_globals.database
self.user_password = u'secret'
self.user = fixture_add_user(u'call_back', self.user_password)
self.login()
开发者ID:imclab,项目名称:mediagoblin,代码行数:8,代码来源:test_http_callback.py
示例17: setup
def setup(self, test_app):
self.test_app = test_app
self.db = mg_globals.database
self.user_password = u'secret'
self.user = fixture_add_user(u'call_back', self.user_password)
self.login()
开发者ID:RichoHan,项目名称:MediaGoblin,代码行数:9,代码来源:test_http_callback.py
示例18: setup
def setup(self, test_app):
self.test_app = test_app
# TODO: Possibly abstract into a decorator like:
# @as_authenticated_user('chris')
test_user = fixture_add_user()
self.test_user = test_user
self.login()
开发者ID:RichoHan,项目名称:MediaGoblin,代码行数:10,代码来源:test_submission.py
示例19: setUp
def setUp(self):
self.app = get_test_app()
self.db = mg_globals.database
self.pman = pluginapi.PluginManager()
self.user_password = '4cc355_70k3N'
self.user = fixture_add_user('joauth', self.user_password)
self.login()
开发者ID:3rdwiki,项目名称:mediagoblin,代码行数:10,代码来源:test_oauth.py
示例20: setup
def setup(self, test_app):
self.test_app = test_app
# TODO: Possibly abstract into a decorator like:
# @as_authenticated_user('chris')
self.test_user = fixture_add_user(privileges=[u"active", u"commenter"])
self.current_user = None
self.login()
开发者ID:vasilenkomike,项目名称:mediagoblin,代码行数:10,代码来源:test_notifications.py
注:本文中的mediagoblin.tests.tools.fixture_add_user函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论