mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-09 19:01:42 +00:00
[tests] Fix tests
This commit is contained in:
@@ -14,7 +14,7 @@ class RepoPublicTest(BaseTestCase):
|
|||||||
self.url = '/api2/repos/%s/public/' % self.repo_id
|
self.url = '/api2/repos/%s/public/' % self.repo_id
|
||||||
self.user_repo_url = '/api2/repos/%s/public/' % self.repo.id
|
self.user_repo_url = '/api2/repos/%s/public/' % self.repo.id
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.remove_repo(self.repo_id)
|
self.remove_repo(self.repo_id)
|
||||||
@@ -46,9 +46,9 @@ class RepoPublicTest(BaseTestCase):
|
|||||||
assert json_resp['success'] is True
|
assert json_resp['success'] is True
|
||||||
|
|
||||||
def test_admin_can_set_pub_repo_when_setting_disalbed(self):
|
def test_admin_can_set_pub_repo_when_setting_disalbed(self):
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = False
|
config.ENABLE_USER_CREATE_ORG_REPO = False
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
self.login_as(self.admin)
|
self.login_as(self.admin)
|
||||||
|
|
||||||
@@ -58,9 +58,9 @@ class RepoPublicTest(BaseTestCase):
|
|||||||
assert json_resp['success'] is True
|
assert json_resp['success'] is True
|
||||||
|
|
||||||
def test_user_can_not_set_pub_repo_when_setting_disalbed(self):
|
def test_user_can_not_set_pub_repo_when_setting_disalbed(self):
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = False
|
config.ENABLE_USER_CREATE_ORG_REPO = False
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
self.login_as(self.user)
|
self.login_as(self.user)
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ class SharedRepoTest(BaseTestCase):
|
|||||||
username=self.admin.username,
|
username=self.admin.username,
|
||||||
passwd=None)
|
passwd=None)
|
||||||
self.shared_repo_url = '/api2/shared-repos/%s/?share_type=public&permission=rw'
|
self.shared_repo_url = '/api2/shared-repos/%s/?share_type=public&permission=rw'
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.remove_repo(self.repo_id)
|
self.remove_repo(self.repo_id)
|
||||||
@@ -34,9 +34,9 @@ class SharedRepoTest(BaseTestCase):
|
|||||||
assert "success" in resp.content
|
assert "success" in resp.content
|
||||||
|
|
||||||
def test_admin_can_set_pub_repo_when_setting_disalbed(self):
|
def test_admin_can_set_pub_repo_when_setting_disalbed(self):
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = False
|
config.ENABLE_USER_CREATE_ORG_REPO = False
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
self.login_as(self.admin)
|
self.login_as(self.admin)
|
||||||
|
|
||||||
@@ -45,9 +45,9 @@ class SharedRepoTest(BaseTestCase):
|
|||||||
assert "success" in resp.content
|
assert "success" in resp.content
|
||||||
|
|
||||||
def test_user_can_not_set_pub_repo_when_setting_disalbed(self):
|
def test_user_can_not_set_pub_repo_when_setting_disalbed(self):
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = False
|
config.ENABLE_USER_CREATE_ORG_REPO = False
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
self.login_as(self.user)
|
self.login_as(self.user)
|
||||||
|
|
||||||
|
@@ -30,15 +30,15 @@ class LibrariesTest(BaseTestCase):
|
|||||||
# user
|
# user
|
||||||
self.login_as(self.user)
|
self.login_as(self.user)
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert resp.context['can_add_pub_repo'] is True
|
assert resp.context['can_add_pub_repo'] is True
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 0
|
config.ENABLE_USER_CREATE_ORG_REPO = 0
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
@@ -50,15 +50,15 @@ class LibrariesTest(BaseTestCase):
|
|||||||
# admin
|
# admin
|
||||||
self.login_as(self.admin)
|
self.login_as(self.admin)
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert resp.context['can_add_pub_repo'] is True
|
assert resp.context['can_add_pub_repo'] is True
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 0
|
config.ENABLE_USER_CREATE_ORG_REPO = 0
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
@@ -11,15 +11,15 @@ class LibrariesTests(BaseTestCase):
|
|||||||
# user
|
# user
|
||||||
self.login_as(self.user)
|
self.login_as(self.user)
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert resp.context['can_add_pub_repo'] is True
|
assert resp.context['can_add_pub_repo'] is True
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 0
|
config.ENABLE_USER_CREATE_ORG_REPO = 0
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
@@ -31,15 +31,15 @@ class LibrariesTests(BaseTestCase):
|
|||||||
# admin
|
# admin
|
||||||
self.login_as(self.admin)
|
self.login_as(self.admin)
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 1
|
config.ENABLE_USER_CREATE_ORG_REPO = 1
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is True
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is True
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
assert resp.context['can_add_pub_repo'] is True
|
assert resp.context['can_add_pub_repo'] is True
|
||||||
|
|
||||||
config.ENABLE_ORGANIZATION_LIBRARY = 0
|
config.ENABLE_USER_CREATE_ORG_REPO = 0
|
||||||
assert bool(config.ENABLE_ORGANIZATION_LIBRARY) is False
|
assert bool(config.ENABLE_USER_CREATE_ORG_REPO) is False
|
||||||
|
|
||||||
resp = self.client.get(self.url)
|
resp = self.client.get(self.url)
|
||||||
self.assertEqual(200, resp.status_code)
|
self.assertEqual(200, resp.status_code)
|
||||||
|
Reference in New Issue
Block a user