1
from __future__ import print_function
3
from . import helpers as test_helpers
5
from cloudinit.cs_utils import Cepko
10
"cpus_instead_of_cores": False,
11
"global_context": {"some_global_key": "some_global_val"},
13
"meta": {"ssh_public_key": "ssh-rsa AAAAB3NzaC1yc2E.../hQ5D5 john@doe"},
14
"name": "test_server",
17
"tags": ["much server", "very performance"],
18
"uuid": "65b2fb23-8c03-4187-a3ba-8b7c919e889",
19
"vnc_password": "9e84d6cb49e46379"
23
class CepkoMock(Cepko):
27
def get(self, key="", request_pattern=None):
28
return SERVER_CONTEXT['tags']
31
# 2015-01-22 BAW: This test is completely useless because it only ever tests
32
# the CepkoMock object. Even in its original form, I don't think it ever
33
# touched the underlying Cepko class methods.
34
class CepkoResultTests(test_helpers.TestCase):
36
raise test_helpers.SkipTest('This test is completely useless')
38
def test_getitem(self):
40
self.assertEqual("65b2fb23-8c03-4187-a3ba-8b7c919e889", result['uuid'])
41
self.assertEqual([], result['requirements'])
42
self.assertEqual("much server", result['tags'][0])
43
self.assertEqual(1, result['smp'])
46
self.assertEqual(len(SERVER_CONTEXT), len(self.c.all()))
48
def test_contains(self):
50
self.assertTrue('uuid' in result)
51
self.assertFalse('uid' in result)
52
self.assertTrue('meta' in result)
53
self.assertFalse('ssh_public_key' in result)
56
self.assertEqual(sorted(SERVER_CONTEXT.keys()),
57
sorted([key for key in self.c.all()]))
59
def test_with_list_as_result(self):
60
result = self.c.get('tags')
61
self.assertEqual('much server', result[0])
62
self.assertTrue('very performance' in result)
63
self.assertEqual(2, len(result))