Revision 14b5cd0e kamaki/clients/astakos/test.py
b/kamaki/clients/astakos/test.py | ||
---|---|---|
98 | 98 |
def tearDown(self): |
99 | 99 |
FR.json = example |
100 | 100 |
|
101 |
@patch('%s.LoggedAstakosClient.__init__' % astakos_pkg, return_value=None) |
|
101 | 102 |
@patch( |
102 |
'%s.SynnefoAstakosClient.__init__' % astakos_pkg, return_value=None) |
|
103 |
@patch( |
|
104 |
'%s.SynnefoAstakosClient.get_endpoints' % astakos_pkg, |
|
103 |
'%s.LoggedAstakosClient.get_endpoints' % astakos_pkg, |
|
105 | 104 |
return_value=example) |
106 | 105 |
def _authenticate(self, get_endpoints, sac): |
107 | 106 |
r = self.client.authenticate() |
... | ... | |
187 | 186 |
self.assertEqual(r[0]['auth_token'], self.token) |
188 | 187 |
|
189 | 188 |
@patch( |
190 |
'%s.SynnefoAstakosClient.get_usernames' % astakos_pkg,
|
|
189 |
'%s.LoggedAstakosClient.get_usernames' % astakos_pkg,
|
|
191 | 190 |
return_value={42: 'username42', 43: 'username43'}) |
192 | 191 |
def test_uuids2usernames(self, get_usernames): |
193 | 192 |
from astakosclient import AstakosClientException |
194 | 193 |
self.assertRaises( |
195 | 194 |
AstakosClientException, self.client.uuids2usernames, [42, 43]) |
196 | 195 |
with patch( |
197 |
'%s.SynnefoAstakosClient.__init__' % astakos_pkg,
|
|
196 |
'%s.LoggedAstakosClient.__init__' % astakos_pkg,
|
|
198 | 197 |
return_value=None) as sac: |
199 | 198 |
with patch( |
200 |
'%s.SynnefoAstakosClient.get_endpoints' % astakos_pkg,
|
|
199 |
'%s.LoggedAstakosClient.get_endpoints' % astakos_pkg,
|
|
201 | 200 |
return_value=example) as get_endpoints: |
202 | 201 |
r = self.client.uuids2usernames([42, 43]) |
203 | 202 |
self.assert_dicts_are_equal( |
... | ... | |
208 | 207 |
self.assertEqual(get_usernames.mock_calls[-1], call([42, 43])) |
209 | 208 |
|
210 | 209 |
@patch( |
211 |
'%s.SynnefoAstakosClient.get_uuids' % astakos_pkg,
|
|
210 |
'%s.LoggedAstakosClient.get_uuids' % astakos_pkg,
|
|
212 | 211 |
return_value={'username42': 42, 'username43': 43}) |
213 | 212 |
def test_usernames2uuids(self, get_uuids): |
214 | 213 |
from astakosclient import AstakosClientException |
215 | 214 |
self.assertRaises( |
216 | 215 |
AstakosClientException, self.client.usernames2uuids, ['u1', 'u2']) |
217 | 216 |
with patch( |
218 |
'%s.SynnefoAstakosClient.__init__' % astakos_pkg,
|
|
217 |
'%s.LoggedAstakosClient.__init__' % astakos_pkg,
|
|
219 | 218 |
return_value=None) as sac: |
220 | 219 |
with patch( |
221 |
'%s.SynnefoAstakosClient.get_endpoints' % astakos_pkg,
|
|
220 |
'%s.LoggedAstakosClient.get_endpoints' % astakos_pkg,
|
|
222 | 221 |
return_value=example) as get_endpoints: |
223 | 222 |
r = self.client.usernames2uuids(['u1', 'u2']) |
224 | 223 |
self.assert_dicts_are_equal( |
Also available in: Unified diff