diff --git a/tests/api/endpoints/test_user.py b/tests/api/endpoints/test_user.py index 5678d51fb31..29bbf570533 100644 --- a/tests/api/endpoints/test_user.py +++ b/tests/api/endpoints/test_user.py @@ -6,9 +6,7 @@ from django.urls import reverse from seahub.test_utils import BaseTestCase -from seahub.base.templatetags.seahub_tags import email2nickname, \ - email2contact_email -from seahub.profile.models import Profile, DetailedProfile +from seahub.profile.models import Profile from seahub.base.accounts import UserManager @@ -19,14 +17,8 @@ def generate_random_parammeter(min_len, max_len, param_type): random_nickname = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(random_nickname_length)) return random_nickname, random_nickname_length - elif param_type == 'telephone': - random_telephone_length = random.randint(min_len, max_len) - random_telephone = ''.join(random.choice(string.digits) for _ in range(random_telephone_length)) - return random_telephone, random_telephone_length - elif param_type == 'contact_email': random_pre_length = random.randint(1, 50) - random_post_length = random.randint(1, 20) random_contact_email = ''.join(random.choice(string.digits + string.ascii_letters) for _ in range(random_pre_length))\ + '@' \ + ''.join(random.choice(string.digits + string.ascii_letters) for _ in range(random_pre_length))\ @@ -43,6 +35,7 @@ def generate_random_parammeter(min_len, max_len, param_type): random_loginid = ''.join(random.choice(string.digits + string.ascii_letters) for _ in range(random_loginid_length)) return random_loginid + class AccountTest(BaseTestCase): def setUp(self): @@ -57,17 +50,11 @@ def test_get_info(self): self.login_as(self.user) random_login_id = generate_random_parammeter(0, 0, 'login_id') - random_telephone, _ = generate_random_parammeter(1, 100, 'telephone') Profile.objects.add_or_update( self.user_name, login_id=random_login_id ) - d_profile = DetailedProfile.objects.add_or_update( - self.user_name, - department='', - telephone=random_telephone - ) profile = Profile.objects.get_profile_by_user(self.user_name) resp = self.client.get(self.url) @@ -75,7 +62,6 @@ def test_get_info(self): assert json_resp['email'] == self.user_name assert json_resp['name'] == (profile.nickname if profile.nickname else '') assert json_resp['contact_email'] == (profile.contact_email if profile.contact_email else '') - assert json_resp['telephone'] == d_profile.telephone assert json_resp['login_id'] == profile.login_id assert 'list_in_address_book' in json_resp @@ -103,25 +89,6 @@ def test_update_user_nickname(self): resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded') self.assertEqual(400, resp.status_code) - def test_update_user_telephone(self): - - self.login_as(self.user) - Profile.objects.add_or_update(self.user_name) - DetailedProfile.objects.add_or_update(self.user_name, department='', telephone='') - - # test can successfully change telephone - random_telephone, _ = generate_random_parammeter(1, 100, 'telephone') - data = 'telephone=%s' % random_telephone - resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded') - json_resp = json.loads(resp.content) - assert json_resp['telephone'] == random_telephone - - # telephone too long - random_telephone, _ = generate_random_parammeter(101, 500, 'telephone') - data = 'telephone=%s' % random_telephone - resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded') - self.assertEqual(400, resp.status_code) - @patch('seahub.api2.endpoints.user.ENABLE_USER_SET_CONTACT_EMAIL', False) def test_update_user_contact_email_feature_disabled(self): self.login_as(self.user) @@ -131,10 +98,8 @@ def test_update_user_contact_email_feature_disabled(self): random_contact_email = generate_random_parammeter(0, 0, 'contact_email') data = 'contact_email=%s' % random_contact_email resp = self.client.put(self.url, data, 'application/x-www-form-urlencoded') - json_resp = json.loads(resp.content) self.assertEqual(403, resp.status_code) - @patch('seahub.api2.endpoints.user.ENABLE_USER_SET_CONTACT_EMAIL', True) def test_update_user_contact_email(self):