本文整理汇总了Python中account.models.User.kind方法的典型用法代码示例。如果您正苦于以下问题:Python User.kind方法的具体用法?Python User.kind怎么用?Python User.kind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.kind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_status
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import kind [as 别名]
def test_status(self):
username = 'admin'
password = 'station1'
user = User(username=username)
user.set_password(password)
user.kind = User.ADMIN
user.save()
# login
data = {'username': username, 'password': password,
'api_key': settings.API_KEY, 'version': settings.API_VERSION}
client = APIClient()
client.post(reverse('register'), data, format='json')
try:
session = Session.objects.get(user=user)
except:
session = None
else:
url = '/api/status'
data = {
'token': session.token,
'api_key': settings.API_KEY, 'version': settings.API_VERSION,
}
response = self.client.post(url, data)
示例2: test_null_station_id
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import kind [as 别名]
def test_null_station_id(self):
username = 'station2'
password = 'station2'
user = User(username=username)
user.set_password(password)
user.kind = User.STATION
user.save()
station = Station()
station.name = 'no name'
station.user = user
station.max_sessions = 3
station.save()
# login
data = {'username': username, 'password': password,
'api_key': settings.API_KEY}
client = APIClient()
client.post(reverse('general:register'), data, format='json')
try:
session = Session.objects.get(user=user)
except:
session = None
data = {'token': session.token,
'api_key': settings.API_KEY}
response = self.client.post(self.url, data)
self.assertEqual(response.data, {'status': 'error', 'reason': 'station_error'})
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)