1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
##############################################################################
# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
import unittest
from yardstick.benchmark.contexts import base
from yardstick.benchmark.contexts import dummy
class DummyContextTestCase(unittest.TestCase):
def setUp(self):
self.attrs = {
'name': 'foo',
'task_id': '1234567890',
}
self.test_context = dummy.DummyContext()
self.addCleanup(self._delete_contexts)
@staticmethod
def _delete_contexts():
for context in base.Context.list:
context._delete_context()
def test___init__(self):
self.assertFalse(self.test_context._flags.no_setup)
self.assertFalse(self.test_context._flags.no_teardown)
self.assertIsNone(self.test_context._name)
self.assertIsNone(self.test_context._task_id)
def test_init(self):
self.test_context.init(self.attrs)
self.assertEqual(self.test_context._name, 'foo')
self.assertEqual(self.test_context._task_id, '1234567890')
self.assertFalse(self.test_context._flags.no_setup)
self.assertFalse(self.test_context._flags.no_teardown)
self.assertEqual(self.test_context.name, 'foo-12345678')
self.assertEqual(self.test_context.assigned_name, 'foo')
def test_init_flags_no_setup(self):
self.attrs['flags'] = {'no_setup': True, 'no_teardown': False}
self.test_context.init(self.attrs)
self.assertEqual(self.test_context._name, 'foo')
self.assertEqual(self.test_context._task_id, '1234567890')
self.assertTrue(self.test_context._flags.no_setup)
self.assertFalse(self.test_context._flags.no_teardown)
self.assertEqual(self.test_context.name, 'foo')
self.assertEqual(self.test_context.assigned_name, 'foo')
def test_init_flags_no_teardown(self):
self.attrs['flags'] = {'no_setup': False, 'no_teardown': True}
self.test_context.init(self.attrs)
self.assertFalse(self.test_context._flags.no_setup)
self.assertTrue(self.test_context._flags.no_teardown)
self.assertEqual(self.test_context.name, 'foo')
self.assertEqual(self.test_context.assigned_name, 'foo')
def test__get_server(self):
self.test_context.init(self.attrs)
self.test_context.deploy()
result = self.test_context._get_server(None)
self.assertEqual(result, None)
self.test_context.undeploy()
def test__get_physical_nodes(self):
result = self.test_context._get_physical_nodes()
self.assertIsNone(result)
def test__get_physical_node_for_server(self):
result = self.test_context._get_physical_node_for_server("fake")
self.assertIsNone(result)
|