1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 00:43:53 +00:00

6.3 fix test (#2264)

* wip: Fix tests

* [tests] Update
This commit is contained in:
zheng xie
2018-08-08 10:22:26 +08:00
committed by GitHub
parent bd8a6a6105
commit 8d5fcd0557
6 changed files with 80 additions and 29 deletions

View File

@@ -1,7 +1,10 @@
language: python
env:
global:
- CCNET_CONF_DIR=/tmp/ccnet SEAFILE_CONF_DIR=/tmp/seafile-data
- secure: "AFqKit45l2758+TrH/l0SFN6k5lc9ALmZGPBGbGeYSzSGZ4+Cx7tHyQwgZgiitf9BzVci1ClaIMfNxp8BG6ECDAMXcbMyAksItG2aM/x//YT59ljgrwnNeZFfwh8LWuZslboxXx/Pfrv9QSX0c6dcTyEfKFLVKW1U2bn4MxdF+A="
# install & start seafile-server CE v6.3, install phantomjs & nginx
before_install:
@@ -10,21 +13,23 @@ before_install:
- cd /tmp/seafile-test-deploy && ./bootstrap.sh && cd -
# install phantomjs
- ./tests/install-deps.sh
- npm install -g requirejs
- openssl aes-256-cbc -K $encrypted_bdef00a70236_key -iv $encrypted_bdef00a70236_iv -in .travis/travis_deploy_key.enc -out travis_deploy_key -d && mv travis_deploy_key ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
# install seahub requirements
install:
- pip install -r requirements.txt --allow-all-external --allow-unverified PIL
- pip install -r test-requirements.txt
# int & start seahub server
before_scipt:
- ./tests/seahubtests.sh init && ./tests/seahubtests.sh runserver
before_scipt: true
# run seahub tests
# int & start seahub server, run seahub tests
script:
- ./tests/seahubtests.sh test
- ./tests/seahubtests.sh init && ./tests/seahubtests.sh runserver && ./tests/seahubtests.sh test
after_success: true
after_success:
- ./tests/seahubtests.sh dist
- .travis/dist_and_push.sh
after_failure: true
@@ -42,3 +47,4 @@ branches:
- master
- 6.3
- 6.2
- 6.3-fix_test

20
.travis/dist_and_push.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/sh
commit_media_files() {
git checkout -b dist-$TRAVIS_BRANCH
git add -u . && git add -A media/assets && git add -A static/scripts
git commit -m "[dist] Travis build: #$TRAVIS_BUILD_NUMBER, based on commit $TRAVIS_COMMIT." -m "https://travis-ci.org/haiwen/seahub/builds/$TRAVIS_BUILD_ID" -m "$TRAVIS_COMMIT_MESSAGE"
}
upload_files() {
git push git@github.com:haiwen/seahub.git dist-$TRAVIS_BRANCH -f
}
make_dist() {
make dist
}
# make_dist
commit_media_files
upload_files

Binary file not shown.

View File

@@ -35,6 +35,15 @@ class SharedReposTest(BaseTestCase):
self.admin_name = self.admin.username
self.url = reverse('api-v2.1-shared-repos')
# make sure this user has not sharing any repos
for x in seafile_api.get_share_out_repo_list(self.user_name, -1, -1):
seafile_api.remove_share(x.repo_id, self.user_name, x.user)
assert len(seafile_api.get_share_out_repo_list(self.user_name, -1, -1)) == 0
for x in seafile_api.get_group_repos_by_owner(self.user_name):
seafile_api.unset_group_repo(x.repo_id, x.group_id, self.user_name)
assert len(seafile_api.get_group_repos_by_user(self.user_name)) == 0
def tearDown(self):
seafile_api.remove_share(self.repo_id, self.user_name, self.admin_name)
seafile_api.unset_group_repo(self.repo_id, self.group_id, self.user_name)
@@ -52,18 +61,22 @@ class SharedReposTest(BaseTestCase):
p.save()
self.login_as(self.user)
resp = self.client.get(self.url)
resp = self.client.get(self.url + '?share_type=personal')
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert json_resp[0]['share_type'] == 'personal'
assert json_resp[0]['repo_id'] == self.repo_id
assert json_resp[0]['user_email'] == self.admin_name
assert json_resp[0]['user_name'] == nickname
assert json_resp[0]['contact_email'] == contact_email
assert len(json_resp[0]['modifier_email']) > 0
assert len(json_resp[0]['modifier_name']) > 0
assert len(json_resp[0]['modifier_contact_email']) > 0
assert 'personal' in [x['share_type'] for x in json_resp]
for r in json_resp:
if r['share_type'] != 'personal':
continue
assert r['repo_id'] == self.repo_id
assert r['user_email'] == self.admin_name
assert r['user_name'] == nickname
assert r['contact_email'] == contact_email
assert len(r['modifier_email']) > 0
assert len(r['modifier_name']) > 0
assert len(r['modifier_contact_email']) > 0
def test_can_get_when_share_to_group(self):
self.share_repo_to_group()
@@ -73,9 +86,13 @@ class SharedReposTest(BaseTestCase):
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert json_resp[0]['share_type'] == 'group'
assert json_resp[0]['repo_id'] == self.repo_id
assert json_resp[0]['group_id'] == self.group_id
assert 'group' in [x['share_type'] for x in json_resp]
for r in json_resp:
if r['share_type'] != 'group':
continue
assert r['repo_id'] == self.repo_id
assert r['group_id'] == self.group_id
@pytest.mark.skipif(TRAVIS, reason="") # pylint: disable=E1101
def test_can_get_when_share_to_org_group(self):
@@ -85,6 +102,7 @@ class SharedReposTest(BaseTestCase):
resp = self.client.get(self.url)
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert len(json_resp) == 1
assert json_resp[0]['share_type'] == 'group'
assert json_resp[0]['repo_id'] == self.org_repo.id
@@ -94,11 +112,11 @@ class SharedReposTest(BaseTestCase):
self.share_repo_to_public()
self.login_as(self.user)
resp = self.client.get(self.url)
resp = self.client.get(self.url + '?share_type=public')
self.assertEqual(200, resp.status_code)
json_resp = json.loads(resp.content)
assert json_resp[0]['share_type'] == 'public'
assert 'public' in [x['share_type'] for x in json_resp]
def test_get_with_invalid_repo_permission(self):

View File

@@ -174,18 +174,17 @@ class BatchAddUserTest(BaseTestCase):
self.new_users = []
self.excel_file = os.path.join(os.getcwd(), 'tests/seahub/views/sysadmin/batch_add_user.xlsx')
data_list = []
data_list.append(['email', 'password', 'username', 'department', 'role', 'quota'])
data_list.append(['email', 'password', 'username', 'role', 'quota'])
for i in xrange(20):
username = "username@test" + str(i) +".com"
password = "password"
name = "name_test" + str(i)
department = "department_test" + str(i)
if i < 10:
role = "guest"
else:
role = "default"
quota = "999"
data_list.append([username, password, name, department, role, quota])
data_list.append([username, password, name, role, quota])
self.new_users.append(username)
wb = real_write_xls('test', data_list[0], data_list[1:])
wb.save(self.excel_file)
@@ -318,7 +317,6 @@ class BatchAddUserHelpTest(BaseTestCase):
assert r[0].value == 'test' + str(i) + '@example.com'
assert r[1].value == '123456'
assert r[2].value == 'test' + str(i)
assert r[3].value == 'department' + str(i)
assert r[4].value == 'default'
assert r[5].value == '1000'
assert r[3].value == 'default'
assert r[4].value == '1000'
i += 1

View File

@@ -54,6 +54,12 @@ function start_seahub() {
sleep 5
}
function make_dist() {
echo "Making dist files ..."
make dist
}
function check_phantom_js() {
if ! which phantomjs >/dev/null; then
echo "Please install phantojs first:"
@@ -71,7 +77,7 @@ function run_tests() {
rvalue=$?
if [[ ${TRAVIS} != "" ]]; then
# On travis-ci, dump seahub logs when test finished
for logfile in /tmp/seahub*.log; do
for logfile in /tmp/ccnet/*.log /tmp/seafile-data/*.log /tmp/seahub*.log; do
echo -e "\nLog file $logfile:\n"
cat "${logfile}"
echo
@@ -87,6 +93,9 @@ case $1 in
"runserver")
start_seahub
;;
"dist")
make_dist
;;
"test")
shift
nose_opts=$*