Revision fd7a8661
b/snf-pithos-tools/pithos/tools/test.py | ||
---|---|---|
62 | 62 |
from pithos.api.settings import AUTHENTICATION_USERS |
63 | 63 |
AUTHENTICATION_USERS = AUTHENTICATION_USERS or {} |
64 | 64 |
OTHER_ACCOUNTS = AUTHENTICATION_USERS.copy() |
65 |
OTHER_ACCOUNTS.pop(get_auth()) |
|
65 |
try: |
|
66 |
OTHER_ACCOUNTS.pop(get_auth()) |
|
67 |
except: |
|
68 |
pass |
|
66 | 69 |
|
67 | 70 |
class BaseTestCase(unittest.TestCase): |
68 | 71 |
#TODO unauthorized request |
... | ... | |
1854 | 1857 |
self.client.create_container('c') |
1855 | 1858 |
for i in range(2): |
1856 | 1859 |
self.upload_random_data('c1', 'o%s' %i) |
1857 |
accounts = OTHER_ACCOUNTS.copy() |
|
1858 |
self.o1_sharing = accounts.popitem() |
|
1859 |
self.client.share_object('c1', 'o1', (self.o1_sharing[1],), read=True) |
|
1860 |
if not OTHER_ACCOUNTS: |
|
1861 |
raise Warning('No other accounts avalaible to run this test.') |
|
1862 |
for token, account in OTHER_ACCOUNTS.items(): |
|
1863 |
self.o1_sharing = token, account |
|
1864 |
self.client.share_object('c1', 'o1', (account,), read=True) |
|
1865 |
break |
|
1860 | 1866 |
|
1861 |
l = [] |
|
1862 |
for i in range(len(OTHER_ACCOUNTS) - 1): |
|
1863 |
l.append(accounts.popitem()) |
|
1864 |
|
|
1865 | 1867 |
def tearDown(self): |
1866 | 1868 |
pass |
1867 | 1869 |
|
... | ... | |
1976 | 1978 |
self.assertEqual(l, '') |
1977 | 1979 |
self.assertEqual([], func(*args, format='json', **kwargs)) |
1978 | 1980 |
|
1979 |
class TestGreek(BaseTestCase):
|
|
1981 |
class TestUTF8(BaseTestCase):
|
|
1980 | 1982 |
def test_create_container(self): |
1981 | 1983 |
self.client.create_container('φάκελος') |
1982 | 1984 |
self.assert_container_exists('φάκελος') |
... | ... | |
2104 | 2106 |
|
2105 | 2107 |
def test_groups(self): |
2106 | 2108 |
#create a group |
2107 |
groups = {'σεφς':'chazapis,διογένης'}
|
|
2109 |
groups = {'γκρουπ':'chazapis,διογένης'}
|
|
2108 | 2110 |
self.client.set_account_groups(**groups) |
2109 | 2111 |
groups.update(self.initial_groups) |
2110 |
self.assertEqual(groups['σεφς'],
|
|
2111 |
self.client.retrieve_account_groups()['σεφς'])
|
|
2112 |
self.assertEqual(groups['γκρουπ'],
|
|
2113 |
self.client.retrieve_account_groups()['γκρουπ'])
|
|
2112 | 2114 |
|
2113 | 2115 |
#check read access |
2114 | 2116 |
self.client.create_container('φάκελος') |
2115 | 2117 |
o = self.upload_random_data('φάκελος', 'ο1') |
2116 |
self.client.share_object('φάκελος', 'ο1', ['%s:σεφς' % get_user()]) |
|
2118 |
self.client.share_object('φάκελος', 'ο1', ['%s:γκρουπ' % get_user()]) |
|
2119 |
if 'διογένης' not in OTHER_ACCOUNTS.values(): |
|
2120 |
raise Warning('No such an account exists for running this test.') |
|
2117 | 2121 |
chef = Pithos_Client(get_url(), |
2118 | 2122 |
'0009', |
2119 | 2123 |
'διογένης') |
... | ... | |
2166 | 2170 |
class TestPermissions(BaseTestCase): |
2167 | 2171 |
def setUp(self): |
2168 | 2172 |
BaseTestCase.setUp(self) |
2169 |
|
|
2173 |
|
|
2174 |
if not OTHER_ACCOUNTS: |
|
2175 |
raise Warning('No other accounts avalaible to run this test.') |
|
2176 |
|
|
2170 | 2177 |
#create a group |
2171 | 2178 |
self.authorized = ['chazapis', 'verigak', 'gtsouk'] |
2172 | 2179 |
groups = {'pithosdev':','.join(self.authorized)} |
Also available in: Unified diff