1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 15:38:15 +00:00

[api] file modifier

This commit is contained in:
zming
2017-06-13 11:26:45 +08:00
parent 14df2bcffd
commit 3edfe92f60
6 changed files with 70 additions and 6 deletions

View File

@@ -1,9 +1,14 @@
import json
import os
import time
from django.core.urlresolvers import reverse
from django.core.cache import cache
from seahub.test_utils import BaseTestCase
from seahub.profile.models import Profile
from seahub.base.templatetags.seahub_tags import email2nickname, email2contact_email
from seahub.utils import normalize_cache_key
class DirTest(BaseTestCase):
def setUp(self):
@@ -35,3 +40,27 @@ class DirTest(BaseTestCase):
})
self.assertEqual(400, resp.status_code)
def test_get_dir_file_modifier(self):
# upload the file , then test whether can get modifier
self.login_as(self.user)
self.text = self.create_file(repo_id=self.repo.id,
parent_dir='/',
filename='test.az',
username=self.user.username)
resp = self.client.get(self.endpoint)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert json_resp[1]['type'] == 'file'
assert json_resp[1]['modifier_email'] == self.user.username
assert json_resp[1]['modifier_name'] == \
email2nickname(self.user.username)
assert json_resp[1]['modifier_contact_email'] == \
email2contact_email(self.user.username)
p = Profile.objects.add_or_update(self.user.username,
'test')
p = Profile.objects.update_contact_email(self.user.username, self.user.username)
assert cache.get(normalize_cache_key(self.user.username, 'CONTACT_')) == \
self.user.username