From 24232c85f790d2c257eaf287ca4f68ca7c4179b0 Mon Sep 17 00:00:00 2001 From: zMingGit <517046497@qq.com> Date: Wed, 6 Sep 2017 15:35:23 +0800 Subject: [PATCH] Profile default (#1793) * profile -> institution test * fix --- seahub/profile/models.py | 2 +- tests/api/endpoints/test_account.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/seahub/profile/models.py b/seahub/profile/models.py index 69d1f4a491..d6576c0cbc 100644 --- a/seahub/profile/models.py +++ b/seahub/profile/models.py @@ -100,7 +100,7 @@ class Profile(models.Model): login_id = models.CharField(max_length=225, unique=True, null=True, blank=True) # Contact email is used to receive emails. contact_email = models.EmailField(max_length=225, db_index=True, null=True, blank=True) - institution = models.CharField(max_length=225, db_index=True, null=True, blank=True) + institution = models.CharField(max_length=225, db_index=True, null=True, blank=True, default='') objects = ProfileManager() def set_lang_code(self, lang_code): diff --git a/tests/api/endpoints/test_account.py b/tests/api/endpoints/test_account.py index b54c56324f..a980980caf 100644 --- a/tests/api/endpoints/test_account.py +++ b/tests/api/endpoints/test_account.py @@ -14,6 +14,7 @@ from seahub.api2.models import TokenV2 class AccountTest(BaseTestCase): def setUp(self): + self.clear_cache() self.user1 = self.create_user('user_%s@test.com' % randstring(4), is_staff=False) self.user2 = self.create_user('user_%s@test.com' % randstring(4), @@ -269,3 +270,20 @@ class AccountTest(BaseTestCase): resp = self._do_delete() self.assertEqual(200, resp.status_code) + + def test_new_user_get_info_after_edit_profile(self): + new_user = self.create_user("test@new.user", is_staff=True) + self.login_as(new_user) + resp = self.client.post(reverse('edit_profile'), { + 'nickname': 'new nickname' + }) + + resp = self.client.get(reverse('api2-account', args=[new_user.username])) + json_resp = json.loads(resp.content) + assert len(json_resp) == 11 + assert json_resp['email'] == new_user.username + assert json_resp['is_staff'] is True + assert json_resp['is_active'] is True + assert json_resp['usage'] == 0 + assert json_resp['institution'] == '' + self.remove_user(new_user.username)