root / kamaki / clients / livetest / astakos.py @ 17b255c7
History | View | Annotate | Download (3.1 kB)
1 | 6d192774 | Stavros Sachtouris | # Copyright 2012-2013 GRNET S.A. All rights reserved.
|
---|---|---|---|
2 | 6d192774 | Stavros Sachtouris | #
|
3 | 6d192774 | Stavros Sachtouris | # Redistribution and use in source and binary forms, with or
|
4 | 6d192774 | Stavros Sachtouris | # without modification, are permitted provided that the following
|
5 | 6d192774 | Stavros Sachtouris | # conditions are met:
|
6 | 6d192774 | Stavros Sachtouris | #
|
7 | 6d192774 | Stavros Sachtouris | # 1. Redistributions of source code must retain the above
|
8 | 6d192774 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
9 | 6d192774 | Stavros Sachtouris | # disclaimer.
|
10 | 6d192774 | Stavros Sachtouris | #
|
11 | 6d192774 | Stavros Sachtouris | # 2. Redistributions in binary form must reproduce the above
|
12 | 6d192774 | Stavros Sachtouris | # copyright notice, this list of conditions and the following
|
13 | 6d192774 | Stavros Sachtouris | # disclaimer in the documentation and/or other materials
|
14 | 6d192774 | Stavros Sachtouris | # provided with the distribution.
|
15 | 6d192774 | Stavros Sachtouris | #
|
16 | 6d192774 | Stavros Sachtouris | # THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS
|
17 | 6d192774 | Stavros Sachtouris | # OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
18 | 6d192774 | Stavros Sachtouris | # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
19 | 6d192774 | Stavros Sachtouris | # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR
|
20 | 6d192774 | Stavros Sachtouris | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
21 | 6d192774 | Stavros Sachtouris | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
22 | 6d192774 | Stavros Sachtouris | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
23 | 6d192774 | Stavros Sachtouris | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
24 | 6d192774 | Stavros Sachtouris | # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25 | 6d192774 | Stavros Sachtouris | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26 | 6d192774 | Stavros Sachtouris | # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27 | 6d192774 | Stavros Sachtouris | # POSSIBILITY OF SUCH DAMAGE.
|
28 | 6d192774 | Stavros Sachtouris | #
|
29 | 6d192774 | Stavros Sachtouris | # The views and conclusions contained in the software and
|
30 | 6d192774 | Stavros Sachtouris | # documentation are those of the authors and should not be
|
31 | 6d192774 | Stavros Sachtouris | # interpreted as representing official policies, either expressed
|
32 | 6d192774 | Stavros Sachtouris | # or implied, of GRNET S.A.
|
33 | 6d192774 | Stavros Sachtouris | |
34 | f5f2dc53 | Stavros Sachtouris | from kamaki.clients import livetest |
35 | 420598d0 | Stavros Sachtouris | from kamaki.clients.astakos import AstakosClient |
36 | 6d192774 | Stavros Sachtouris | |
37 | 6d192774 | Stavros Sachtouris | |
38 | f5f2dc53 | Stavros Sachtouris | class Astakos(livetest.Generic): |
39 | 6d192774 | Stavros Sachtouris | def setUp(self): |
40 | 420598d0 | Stavros Sachtouris | self.client = AstakosClient(
|
41 | 4018326d | Stavros Sachtouris | self['user', 'url'], |
42 | 4018326d | Stavros Sachtouris | self['user', 'token']) |
43 | 6d192774 | Stavros Sachtouris | |
44 | 6d192774 | Stavros Sachtouris | def test_authenticate(self): |
45 | 409371de | Stavros Sachtouris | self._test_0010_authenticate()
|
46 | 5207c784 | Stavros Sachtouris | |
47 | 409371de | Stavros Sachtouris | def _test_0010_authenticate(self): |
48 | 6d192774 | Stavros Sachtouris | r = self.client.authenticate()
|
49 | 1f0370c9 | Stavros Sachtouris | for term in ( |
50 | 2005b18e | Stavros Sachtouris | 'name',
|
51 | 2005b18e | Stavros Sachtouris | 'username',
|
52 | 2005b18e | Stavros Sachtouris | 'auth_token_expires',
|
53 | 2005b18e | Stavros Sachtouris | 'auth_token_created',
|
54 | 2005b18e | Stavros Sachtouris | 'uuid',
|
55 | 2005b18e | Stavros Sachtouris | 'id',
|
56 | 2005b18e | Stavros Sachtouris | 'email'):
|
57 | 2005b18e | Stavros Sachtouris | self.assertTrue(term in r) |
58 | 5207c784 | Stavros Sachtouris | |
59 | 2182231b | Stavros Sachtouris | def test_info(self): |
60 | 2182231b | Stavros Sachtouris | self._test_0020_info()
|
61 | 2182231b | Stavros Sachtouris | |
62 | 2182231b | Stavros Sachtouris | def _test_0020_info(self): |
63 | 2182231b | Stavros Sachtouris | self.assertTrue(set([ |
64 | 2182231b | Stavros Sachtouris | 'name',
|
65 | 2182231b | Stavros Sachtouris | 'username',
|
66 | 2182231b | Stavros Sachtouris | 'uuid']).issubset(self.client.info().keys())) |
67 | 2182231b | Stavros Sachtouris | |
68 | 5207c784 | Stavros Sachtouris | def test_get(self): |
69 | 409371de | Stavros Sachtouris | self._test_0020_get()
|
70 | 5207c784 | Stavros Sachtouris | |
71 | 409371de | Stavros Sachtouris | def _test_0020_get(self): |
72 | 24ff0a35 | Stavros Sachtouris | for term in ('uuid', 'name', 'username'): |
73 | 2182231b | Stavros Sachtouris | self.assertEqual(
|
74 | 737c7deb | Stavros Sachtouris | self.client.term(term, self['user', 'token']), |
75 | 2182231b | Stavros Sachtouris | self['astakos', term]) |
76 | 5207c784 | Stavros Sachtouris | self.assertTrue(self['astakos', 'email'] in self.client.term('email')) |
77 | 29040fef | Stavros Sachtouris | |
78 | 29040fef | Stavros Sachtouris | def test_list(self): |
79 | 29040fef | Stavros Sachtouris | self.client.authenticate()
|
80 | 409371de | Stavros Sachtouris | self._test_0020_list()
|
81 | 29040fef | Stavros Sachtouris | |
82 | 409371de | Stavros Sachtouris | def _test_0020_list(self): |
83 | 2182231b | Stavros Sachtouris | terms = set(['name', 'username', 'uuid', 'email', 'auth_token']) |
84 | 29040fef | Stavros Sachtouris | uuid = 0
|
85 | 29040fef | Stavros Sachtouris | for r in self.client.list(): |
86 | 29040fef | Stavros Sachtouris | self.assertTrue(terms.issubset(r.keys()))
|
87 | 29040fef | Stavros Sachtouris | self.assertTrue(uuid != r['uuid'] if uuid else True) |
88 | 29040fef | Stavros Sachtouris | uuid = r['uuid'] |