| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
import json |
| 15 |
import os |
| 16 |
|
| 17 |
import io |
| 18 |
|
| 19 |
from heatclient.common import resource_formatter |
| 20 |
from heatclient.osc.v1 import resource |
| 21 |
from heatclient.tests.unit.osc.v1 import fakes as orchestration_fakes |
| 22 |
from heatclient.v1 import resources as v1_resources |
| 23 |
|
| 24 |
|
| 25 |
TEST_VAR_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), |
| 26 |
'var')) |
| 27 |
|
| 28 |
|
| 29 |
class TestStackResourceListDotFormat(orchestration_fakes.TestOrchestrationv1): |
| 30 |
|
| 31 |
response_path = os.path.join(TEST_VAR_DIR, 'dot_test.json') |
| 32 |
|
| 33 |
data = '''digraph G { |
| 34 |
graph [ |
| 35 |
fontsize=10 fontname="Verdana" compound=true rankdir=LR |
| 36 |
] |
| 37 |
r_f34a35baf594b319a741 [label="rg1 |
| 38 |
OS::Heat::ResourceGroup" ]; |
| 39 |
r_121e343b017a6d246f36 [label="random2 |
| 40 |
OS::Heat::RandomString" ]; |
| 41 |
r_dbcae38ad41dc991751d [label="random1 |
| 42 |
OS::Heat::RandomString" style=filled color=red]; |
| 43 |
|
| 44 |
subgraph cluster_stack_16437984473ec64a8e6c { |
| 45 |
label="rg1"; |
| 46 |
r_30e9aa76bc0d53310cde [label="1 |
| 47 |
OS::Heat::ResourceGroup" ]; |
| 48 |
r_63c05d424cb708f1599f [label="0 |
| 49 |
OS::Heat::ResourceGroup" ]; |
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
subgraph cluster_stack_fbfb461c8cc84b686c08 { |
| 54 |
label="1"; |
| 55 |
r_e2e5c36ae18e29d9c299 [label="1 |
| 56 |
OS::Heat::RandomString" ]; |
| 57 |
r_56c62630a0d655bce234 [label="0 |
| 58 |
OS::Heat::RandomString" ]; |
| 59 |
|
| 60 |
} |
| 61 |
|
| 62 |
subgraph cluster_stack_d427657dfccc28a131a7 { |
| 63 |
label="0"; |
| 64 |
r_240756913e2e940387ff [label="1 |
| 65 |
OS::Heat::RandomString" ]; |
| 66 |
r_81c64c43d9131aceedbb [label="0 |
| 67 |
OS::Heat::RandomString" ]; |
| 68 |
|
| 69 |
} |
| 70 |
|
| 71 |
r_f34a35baf594b319a741 -> r_30e9aa76bc0d53310cde [ |
| 72 |
color=dimgray lhead=cluster_stack_16437984473ec64a8e6c arrowhead=none |
| 73 |
]; |
| 74 |
r_30e9aa76bc0d53310cde -> r_e2e5c36ae18e29d9c299 [ |
| 75 |
color=dimgray lhead=cluster_stack_fbfb461c8cc84b686c08 arrowhead=none |
| 76 |
]; |
| 77 |
r_63c05d424cb708f1599f -> r_240756913e2e940387ff [ |
| 78 |
color=dimgray lhead=cluster_stack_d427657dfccc28a131a7 arrowhead=none |
| 79 |
]; |
| 80 |
|
| 81 |
r_dbcae38ad41dc991751d -> r_121e343b017a6d246f36; |
| 82 |
|
| 83 |
} |
| 84 |
''' |
| 85 |
|
| 86 |
def setUp(self): |
| 87 |
super().setUp() |
| 88 |
self.resource_client = self.app.client_manager.orchestration.resources |
| 89 |
self.cmd = resource.ResourceList(self.app, None) |
| 90 |
with open(self.response_path) as f: |
| 91 |
response = json.load(f) |
| 92 |
self.resources = [] |
| 93 |
for r in response['resources']: |
| 94 |
self.resources.append(v1_resources.Resource(None, r)) |
| 95 |
|
| 96 |
def test_resource_list(self): |
| 97 |
out = io.StringIO() |
| 98 |
formatter = resource_formatter.ResourceDotFormatter() |
| 99 |
formatter.emit_list(None, self.resources, out, None) |
| 100 |
|
| 101 |
self.assertEqual(self.data, out.getvalue()) |