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:
@@ -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
|
||||
|
Reference in New Issue
Block a user