class _test_init(_command_init):
- def main(self, client, method=None):
+ def _run(self, client, method=None):
if method:
tests._main([client, method], config=self.config)
else:
tests._main([client], config=self.config)
+ def main(self, client, method=None):
+ return self._run(client, method)
+
@command(test_cmds)
class test_error(_test_init):
@errors.generic.all
def _run(self):
for client in ('pithos', 'cyclades', 'image', 'astakos'):
- super(self.__class__, self).main(client)
+ super(self.__class__, self)._run(client)
def main(self):
self._run()
@errors.generic.all
def _run(self, method=None):
- super(self.__class__, self).main('pithos', method)
+ super(self.__class__, self)._run('pithos', method)
def main(self, method=None):
self._run(method)
@errors.generic.all
def _run(self, method=None):
- super(self.__class__, self).main('cyclades', method)
+ super(self.__class__, self)._run('cyclades', method)
def main(self, method=None):
self._run(method)
@errors.generic.all
def _run(self, method=None):
- super(self.__class__, self).main('image', method)
+ super(self.__class__, self)._run('image', method)
def main(self, method=None):
self._run(method)
@errors.generic.all
def _run(self, method=None):
- super(self.__class__, self).main('astakos', method)
+ super(self.__class__, self)._run('astakos', method)
def main(self, method=None):
self._run(method)
:returns: (dict) authentication information
"""
self.token = token or self.token
- self._cache[token] = self.get('/im/authenticate')
- return self._cache[token].json
+ self._cache[token] = self.get('/im/authenticate').json
+ return self._cache[token]
+
+ def list(self):
+ return self._cache.values()
def _user_info(self, token=None):
token = token or self.token
except KeyError:
return self.authenticate(token)
- def uuid(self, token=None):
- return self._user_info(token)['uuid'].strip()
-
- def name(self, token=None):
- return self._user_info(token)['name'].strip()
-
- def username(self, token=None):
- return self._user_info(token)['username'].strip()
-
- def token_created(self, token=None):
- return self._user_info(token)['auth_token_created'].strip()
-
- def token_expires(self, token=None):
- return self._user_info(token)['auth_token_expires'].strip()
-
- def email(self, token=None):
- return self._user_info(token)['email'].strip()
-
- def id(self, token=None):
- """Internal reference for Astakos objects (not a unique user id)
- For a unique identifier use uuid
- """
- return self._user_info(token)['id'].strip()
+ def term(self, key, token=None):
+ """Get (cached) term, from user credentials"""
+ return self._user_info(token)[key]
# interpreted as representing official policies, either expressed
# or implied, of GRNET S.A.
-from unittest import TestCase, TestSuite, makeSuite, TextTestRunner
+import inspect
+from unittest import TestCase, TestSuite, TextTestRunner
from argparse import ArgumentParser
from sys import stdout
from progress.bar import ShadyBar
return foo(self, value)
return wrap
+
class Generic(TestCase):
_waits = []
self.assertEqual(unicode(v), unicode(d2[k]))
def test_000(self):
- import inspect
+ print('')
methods = [method for method in inspect.getmembers(
self,
predicate=inspect.ismethod)\
suiteFew.addTest(Image(test_method, config))
if len(argv) == 0 or argv[0] == 'astakos':
from kamaki.clients.tests.astakos import Astakos
- if len(argv) == 1:
- suiteFew.addTest(makeSuite(Astakos, config))
- else:
- suiteFew.addTest(Astakos('test_' + argv[1], config))
+ test_method = 'test_%s' % (argv[1] if len(argv) > 1 else '000')
+ suiteFew.addTest(Astakos(test_method, config))
TextTestRunner(verbosity=2).run(suiteFew)
parser = init_parser()
args, argv = parser.parse_known_args()
if len(argv) > 2 or getattr(args, 'help') or len(argv) < 1:
- raise Exception('\tusage: tests.py <group> [command]')
+ raise Exception('\tusage: tests <group> [command]')
main(argv)
self['astakos', 'token'])
def test_authenticate(self):
+ self._test_authenticate()
+
+ def _test_authenticate(self):
r = self.client.authenticate()
for term in (
+ 'name',
'username',
'auth_token_expires',
- 'auth_token',
'auth_token_created',
- 'groups',
- 'uniq',
- 'has_credits',
- 'has_signed_terms'):
+ 'uuid',
+ 'id',
+ 'email'):
self.assertTrue(term in r)
+
+ def test_get(self):
+ self._test_get()
+
+ def _test_get(self):
+ for term in (
+ 'uuid',
+ 'name',
+ 'username'):
+ self.assertEqual(self.client.term(term), self['astakos', term])
+ self.assertTrue(self['astakos', 'email'] in self.client.term('email'))