1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-06-28 16:08:25 +00:00
seahub/tests/api/endpoints/test_user.py
lian 9bdbb1671a Add ENABLE_ADDRESSBOOK_OPT_IN setting
Enable user to choose if show himself in global address book
2017-09-11 11:13:59 +08:00

40 lines
1.3 KiB
Python

import json
from django.core.urlresolvers import reverse
from seahub.test_utils import BaseTestCase
from seahub.base.templatetags.seahub_tags import email2nickname, \
email2contact_email
class AccountTest(BaseTestCase):
def setUp(self):
self.user_name = self.user.username
self.url = reverse('api-v2.1-user')
def tearDown(self):
pass
def test_get_info(self):
self.login_as(self.user)
resp = self.client.get(self.url)
json_resp = json.loads(resp.content)
assert json_resp['email'] == self.user_name
assert json_resp['name'] == email2nickname(self.user_name)
assert json_resp['contact_email'] == email2contact_email(self.user_name)
assert json_resp.has_key('list_in_address_book')
def test_update_list_in_address_book(self):
self.login_as(self.user)
data = {"list_in_address_book": "true"}
resp = self.client.put(self.url, json.dumps(data), 'application/json')
json_resp = json.loads(resp.content)
assert json_resp['list_in_address_book'] is True
data = {"list_in_address_book": "false"}
resp = self.client.put(self.url, json.dumps(data), 'application/json')
json_resp = json.loads(resp.content)
assert json_resp['list_in_address_book'] is False