本文整理汇总了Python中auth.models.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类auth.models.User
的用法示例。
在下文中一共展示了User.put方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_edit_spot_copy
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_edit_spot_copy(self):
spot = models.Spot(title="Legal ID", type="Station ID")
spot.put()
constraint = models.SpotConstraint(dow=1, hour=0, slot=0, spots=[spot.key()])
constraint.put()
author = User(email="test")
author.put()
spot_copy = models.SpotCopy(body="First", spot=spot, author=author)
spot_copy.put()
spot_copy2 = models.SpotCopy(body="You are listening to chirpradio.org", spot=spot, author=author)
spot_copy2.put()
# now edit the second one:
resp = self.client.post(
reverse("traffic_log.editSpotCopy", args=(spot_copy2.key(),)),
{
"spot_key": spot.key(),
"body": "Something else entirely",
"underwriter": "another underwriter",
"expire_on": "",
},
)
self.assertNoFormErrors(resp)
spot_copy = [c for c in spot.all_spot_copy()]
self.assertEqual(sorted([c.body for c in spot_copy]), ["First", "Something else entirely"])
self.assertEqual(sorted([c.underwriter for c in spot_copy]), [None, "another underwriter"])
self.assertEqual(sorted([c.author.email for c in spot_copy]), ["test", "[email protected]"])
示例2: test_edit_spot_copy
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_edit_spot_copy(self):
spot = models.Spot(
title='Legal ID',
type='Station ID')
spot.put()
constraint = models.SpotConstraint(dow=1, hour=0, slot=0, spots=[spot.key()])
constraint.put()
author = User(email='test')
author.put()
spot_copy = models.SpotCopy(
body='First',
spot=spot,
author=author)
spot_copy.put()
spot_copy2 = models.SpotCopy(
body='You are listening to chirpradio.org',
spot=spot,
author=author)
spot_copy2.put()
# now edit the second one:
resp = self.client.post(reverse('traffic_log.editSpotCopy', args=(spot_copy2.key(),)), {
'spot_key': spot.key(),
'body': 'Something else entirely',
'underwriter': 'another underwriter',
'expire_on': ''
})
self.assertNoFormErrors(resp)
spot_copy = [c for c in spot.all_spot_copy()]
self.assertEqual(sorted([c.body for c in spot_copy]), ['First','Something else entirely'])
self.assertEqual(sorted([c.underwriter for c in spot_copy]), [None, 'another underwriter'])
self.assertEqual(sorted([c.author.email for c in spot_copy]), ['test', '[email protected]'])
示例3: test_delete_spot_copy
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_delete_spot_copy(self):
spot = models.Spot(
title='Legal ID',
type='Station ID')
spot.put()
dow=1
hour=0
slot=0
constraint = models.SpotConstraint(dow=dow, hour=hour, slot=slot, spots=[spot.key()])
constraint.put()
author = User(email='test')
author.put()
spot_copy = models.SpotCopy(
body='First',
spot=spot,
author=author)
spot_copy.put()
self.assertEqual(spot.get_spot_copy(dow, hour, slot)[0].body, "First")
# now edit the second one:
resp = self.client.get(reverse('traffic_log.deleteSpotCopy', args=(spot_copy.key(),)))
self.assertEqual([c for c in spot.all_spot_copy()], [])
self.assertEqual(spot.get_spot_copy(dow, hour, slot), (None, False))
示例4: test_non_dj_cannot_create_playlist
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_non_dj_cannot_create_playlist(self):
not_a_dj = User(email="test")
not_a_dj.put()
def make_playlist():
playlist = DJPlaylist(name='funk 45 collection', created_by_dj=not_a_dj)
playlist.put()
self.assertRaises(ValueError, make_playlist)
示例5: test_cannot_delete_someone_elses_track
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_cannot_delete_someone_elses_track(self):
other_user = User(email="[email protected]")
other_user.roles.append(auth.roles.DJ)
other_user.put()
time.sleep(0.4)
other_track = PlaylistTrack(
playlist=self.playlist,
selector=other_user,
freeform_artist_name="Peaches",
freeform_track_title="Rock Show",)
other_track.put()
with fudge.patched_context(playlists.tasks, "_fetch_url", stub_fetch_url):
resp = self.client.get(reverse('playlists_delete_event',
args=[other_track.key()]))
self.assertRedirects(resp, reverse('playlists_landing_page'))
# simulate the redirect:
resp = self.client.get(reverse('playlists_landing_page'))
# should be no change:
context = resp.context[0]
tracks = [t.artist_name for t in context['playlist_events']]
self.assertEquals(tracks, ["Peaches", "Steely Dan"])
示例6: test_make_spot_copy_expire
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_make_spot_copy_expire(self):
spot = models.Spot(
title='Legal ID',
type='Station ID')
spot.put()
constraint = models.SpotConstraint(dow=1, hour=0, slot=0, spots=[spot.key()])
constraint.put()
author = User(email='test')
author.put()
spot_copy = models.SpotCopy(
body='First',
spot=spot,
author=author)
spot_copy.put()
resp = self.client.post(reverse('traffic_log.editSpotCopy', args=(spot_copy.key(),)), {
'spot_key': spot.key(),
'body': 'Something else entirely',
'underwriter': 'another underwriter',
'expire_on': '2/5/2010' # any date in the past
})
self.assertNoFormErrors(resp)
spot_copy = [c for c in spot.all_spot_copy()]
self.assertEqual(spot_copy, [])
示例7: test_deactivate
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_deactivate(self):
us = User(email='[email protected]', external_id=23)
us.put()
resp = self.client.post(self.url, {'external_id': 23})
eq_(resp.status_code, 200)
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.is_active, False)
示例8: test_collisions
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_collisions(self):
us = User(email=self.user['email'])
us.put()
# This might actually happen because some filtering caused
# bad data in production.
another = User(email=self.user['email']) # same email
another.put()
self.sync()
示例9: test_sync_existing_with_dj_role
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_sync_existing_with_dj_role(self):
us = User(email=self.user['email'],
external_id=self.user['member_id'],
roles=[roles.DJ, roles.REVIEWER])
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(set(us.roles), set((roles.DJ, roles.REVIEWER)))
示例10: test_preserve_superuser
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_preserve_superuser(self):
us = User(email=self.user['email'],
external_id=self.user['member_id'],
is_superuser=True)
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.is_superuser, True)
示例11: test_create_irregular_spot
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_create_irregular_spot(self, time_util, global_time_util):
for obj in [time_util, global_time_util]:
obj.provides("chicago_now").returns(datetime.datetime.strptime("2011-09-14 05:10", "%Y-%m-%d %H:%M"))
resp = self.client.post(
reverse("traffic_log.createSpot"),
{
"title": "Legal ID",
"type": "Station ID",
"hour_list": ["2", "5", "7", "13", "23"],
"dow_list": ["1", "3", "7"],
"slot": "24",
},
)
self.assertNoFormErrors(resp)
spot = models.Spot.all().filter("title =", "Legal ID").fetch(1)[0]
dow = set()
hours = set()
constraint_map = {}
for constraint in spot.constraints:
dow.add(constraint.dow)
hours.add(constraint.hour)
constraint_map[(constraint.dow, constraint.hour, constraint.slot)] = constraint
self.assertEqual(dow, set([1L, 3L, 7L]))
self.assertEqual(hours, set([2L, 5L, 7L, 13L, 23L]))
# Check with Wednesday at 5:24am
author = User(email="test")
author.put()
spot_copy = models.SpotCopy(body="body", spot=spot, author=author)
spot_copy.put()
spot.random_spot_copies = [spot_copy.key()]
spot.save()
self.assertEqual(
constraint_map[(3L, 5L, 24L)].url_to_finish_spot(spot),
"/traffic_log/spot-copy/%s/finish?hour=5&dow=3&slot=24" % spot_copy.key(),
)
self.assertEqual(constraint_map[(3L, 5L, 24L)].as_query_string(), "hour=5&dow=3&slot=24")
# spot shows up in DJ view:
resp = self.client.get(reverse("traffic_log.index"))
context = resp.context[0]
slotted_spots = [c for c in context["slotted_spots"]]
spots = [s.title for s in slotted_spots[0].iter_spots()]
for s in spots:
self.assertEqual(s, "Legal ID")
# spot shows up in admin view:
resp = self.client.get(reverse("traffic_log.listSpots"))
context = resp.context[0]
spots = [c.title for c in context["spots"]]
self.assertEqual(spots, ["Legal ID"])
示例12: test_delete_spot
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_delete_spot(self):
spot = models.Spot(
title='Legal ID',
type='Station ID')
spot.put()
self.assertEqual(spot.active, True)
author = User(email='test')
author.put()
spot_copy = models.SpotCopy(body='body',
spot=spot,
author=author)
spot_copy.put()
# assign it to every day of the week at the top of the hour:
constraint_keys = views.saveConstraint(dict(hour_list=range(0,24), dow_list=range(1,8), slot=0))
views.connectConstraintsAndSpot(constraint_keys, spot.key())
resp = self.client.get(reverse('traffic_log.index'))
context = resp.context[0]
slotted_spots = [c for c in context['slotted_spots']]
spots = [s.title for s in slotted_spots[0].iter_spots()]
self.assertEqual(spots[0], spot.title)
resp = self.client.get(reverse('traffic_log.deleteSpot', args=[spot.key()]))
# datastore was cleaned up:
saved_spot = models.Spot.get(spot.key())
self.assertEqual(saved_spot.active, False)
saved_constaints = [s for s in models.SpotConstraint.get(constraint_keys)]
active_spots = []
for constraint in saved_constaints:
for spot in constraint.iter_spots():
active_spots.append(spot)
self.assertEqual(len(active_spots), 0)
# spot is hidden from landing page:
resp = self.client.get(reverse('traffic_log.index'))
context = resp.context[0]
slotted_spots = [c for c in context['slotted_spots']]
active_spots = []
for slot in slotted_spots:
for spot in slot.iter_spots_at_constraint():
active_spots.append(spot)
self.assertEqual(active_spots, [])
# spot is hidden from admin view:
resp = self.client.get(reverse('traffic_log.listSpots'))
context = resp.context[0]
spots = [c.title for c in context['spots']]
self.assertEqual(spots, [])
示例13: test_create_irregular_spot
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_create_irregular_spot(self, time_util, global_time_util):
for obj in [time_util, global_time_util]:
obj.provides('chicago_now').returns(datetime.datetime.strptime('2011-09-14 05:10', '%Y-%m-%d %H:%M'))
resp = self.client.post(reverse('traffic_log.createSpot'),{
'title' : 'Legal ID',
'type' : 'Station ID',
'hour_list' : ['2','5','7','13','23'],
'dow_list' : ['1','3','7'],
'slot' : '24',
})
self.assertNoFormErrors(resp)
spot = models.Spot.all().filter("title =", "Legal ID").fetch(1)[0]
dow = set()
hours = set()
constraint_map = {}
for constraint in spot.constraints:
dow.add(constraint.dow)
hours.add(constraint.hour)
constraint_map[(constraint.dow, constraint.hour, constraint.slot)] = constraint
self.assertEqual(dow,set([1L,3L,7L]))
self.assertEqual(hours,set([2L,5L,7L,13L,23L]))
# Check with Wednesday at 5:24am
author = User(email='test')
author.put()
spot_copy = models.SpotCopy(body='body',
spot=spot,
author=author)
spot_copy.put()
spot.random_spot_copies = [spot_copy.key()]
spot.save()
self.assertEqual(constraint_map[(3L, 5L, 24L)].url_to_finish_spot(spot),
"/traffic_log/spot-copy/%s/finish?hour=5&dow=3&slot=24" % spot_copy.key())
self.assertEqual(constraint_map[(3L, 5L, 24L)].as_query_string(),
"hour=5&dow=3&slot=24")
# spot shows up in DJ view:
resp = self.client.get(reverse('traffic_log.index'))
context = resp.context[0]
slotted_spots = [c for c in context['slotted_spots']]
spots = [s.title for s in slotted_spots[0].iter_spots()]
for s in spots:
self.assertEqual(s, 'Legal ID')
# spot shows up in admin view:
resp = self.client.get(reverse('traffic_log.listSpots'))
context = resp.context[0]
spots = [c.title for c in context['spots']]
self.assertEqual(spots, ['Legal ID'])
示例14: test_create_spot
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_create_spot(self):
resp = self.client.post(
reverse("traffic_log.createSpot"),
{
"title": "Legal ID",
"type": "Station ID",
"hour_list": [str(d) for d in range(0, 24)],
"dow_list": [str(d) for d in range(1, 8)],
"slot": "0",
},
)
self.assertNoFormErrors(resp)
spot = models.Spot.all().filter("title =", "Legal ID").fetch(1)[0]
dow = set()
hours = set()
constraint_map = {}
for constraint in spot.constraints:
dow.add(constraint.dow)
hours.add(constraint.hour)
constraint_map[(constraint.dow, constraint.hour, constraint.slot)] = constraint
self.assertEqual(sorted(dow), range(1, 8))
self.assertEqual(sorted(hours), range(0, 24))
# check with Sunday 12:00pm
author = User(email="test")
author.put()
spot_copy = models.SpotCopy(body="body", spot=spot, author=author)
spot_copy.put()
spot.random_spot_copies = [spot_copy.key()]
spot.save()
self.assertEqual(
constraint_map[(1L, 12L, 0L)].url_to_finish_spot(spot),
"/traffic_log/spot-copy/%s/finish?hour=12&dow=1&slot=0" % spot_copy.key(),
)
self.assertEqual(constraint_map[(1L, 12L, 0L)].as_query_string(), "hour=12&dow=1&slot=0")
# spot shows up in DJ view:
resp = self.client.get(reverse("traffic_log.index"))
context = resp.context[0]
slotted_spots = [c for c in context["slotted_spots"]]
spots = [s.title for s in slotted_spots[0].iter_spots()]
self.assertEqual(spots[0], spot.title)
# spot shows up in admin view:
resp = self.client.get(reverse("traffic_log.listSpots"))
context = resp.context[0]
spots = [c.title for c in context["spots"]]
self.assertEqual(spots, ["Legal ID"])
示例15: test_sync_existing_without_id
# 需要导入模块: from auth.models import User [as 别名]
# 或者: from auth.models.User import put [as 别名]
def test_sync_existing_without_id(self):
us = User(email=self.user['email'])
us.put()
self.sync()
us = User.all().filter('__key__ =', us.key()).fetch(1)[0]
eq_(us.first_name, self.user['name_first'])
eq_(us.last_name, self.user['name_last'])
eq_(us.email, self.user['email'])
eq_(us.dj_name, self.user['nick'])
eq_(us.external_id, self.user['member_id'])
eq_(us.is_superuser, False)
eq_(us.is_active, True)
eq_(us.roles, [roles.DJ])
eq_(User.all().filter('email =', self.user['email']).count(2), 1)