本文整理汇总了Python中application.models.User.put方法的典型用法代码示例。如果您正苦于以下问题:Python User.put方法的具体用法?Python User.put怎么用?Python User.put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类application.models.User
的用法示例。
在下文中一共展示了User.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_user
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import put [as 别名]
def add_user(profile, friends):
user = User(
id=profile['id'].decode('utf-8'),
name=profile['name'].decode('utf-8')
)
for friend in friends['data']:
entry = User.get_or_insert(
friend['id'].decode('utf-8'),
name=friend['name'].decode('utf-8')
)
user.friends.append(entry.key)
user.put()
示例2: test_get_list
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import put [as 别名]
def test_get_list(self):
user_a = User(id='42', name='Foo Bar')
user_b = User.get_or_insert('43', name='Knuth Donald')
user_c = User.get_or_insert('44', name='Lovelace Ada')
user_a.friends.append(user_b.key)
user_a.friends.append(user_c.key)
user_a.put()
rv = self.app.get('/api/friends?profile_id=42')
self.assertEqual(rv.status, '200 OK')
data = json.loads(rv.data)
self.assertEqual(data['count'], 2)
self.assertItemsEqual({'Knuth Donald', 'Lovelace Ada'},
{f['name'] for f in data['friends']})
示例3: UserApiTest
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import put [as 别名]
class UserApiTest(unittest.TestCase, GoogleAuthMixin):
def setUp(self):
for x in models.CELL_BLACK_LIST[:]:
models.CELL_BLACK_LIST.pop()
app.config['TESTING'] = True
self.login('[email protected]', 'testuser')
self.app = app.test_client()
self.user = User(user=users.get_current_user())
self.user.put()
def test_update(self):
rv = self.app.put('/api/v0/user/' + str(self.user.key()),
data=json.dumps({'current_cells': 2}))
self.assertEquals(200, rv.status_code)
js = json.loads(rv.data)
self.assertEquals(2, js['current_cells'])
示例4: test_friends_updated
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import put [as 别名]
def test_friends_updated(self, mocked_graph):
mocked_graph.return_value.get_object.return_value = {'id': '42'}
mocked_graph.return_value.get_connections.return_value = {'data': []}
user = User(id='42', name='Foo Bar', token='101010')
user.put()
User(id='43', name='Knuth Donald', token='101010').put()
update_friendlists(user)
knuth = User.get_by_id('43')
self.assertEqual(len(knuth.friends), 0)
mocked_graph.return_value.get_connections.return_value = {'data': [{
'id': '43', 'name': 'Knuth Donald'
}]}
update_friendlists(user)
knuth = User.get_by_id('43')
self.assertEqual(len(knuth.friends), 1)
self.assertEqual(knuth.friends[0], user.key)
示例5: setMockUser
# 需要导入模块: from application.models import User [as 别名]
# 或者: from application.models.User import put [as 别名]
def setMockUser(self, access_token=FAKE_ACCESS_TOKEN, username='voidfiles', id=3):
user_data = self.buildMockUserResponse(username=username, id=id)
memcache.set('user:%s' % access_token, json.dumps(user_data), 60 * 60)
user = User(access_token=access_token)
user.put()