Skip to content

Commit

Permalink
test file for ucs service profile
Browse files Browse the repository at this point in the history
  • Loading branch information
Thijs Schnitger committed May 4, 2016
1 parent dd83cbf commit 71f5408
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/test_ucs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- coding: utf-8 -*-
import pytest


@pytest.fixture
def ucs_host():
from terraform import ucs_host
return ucs_host


@pytest.fixture
def ucs_resource():
return {
"type": "ucs_service_profile",
"primary": {
"id": "control-0.mydomain.com",
"attributes": {
"dn": "org-root/ls-control-0.mydomain.com",
"id": "control-0.mydomain.com",
"metadata.#": "1",
"metadata.role": "control",
"name": "control-0.mydomain.com",
"service_profile_template": "CentOS",
"target_org": "org-root",
"vNIC.#": "1",
"vNIC.0.cidr": "10.30.0.150/24",
"vNIC.0.ip": "10.30.0.172",
"vNIC.0.mac": "00:25:B5:00:0A:08",
"vNIC.0.name": "eth0"
},
"meta": {"schema_version": "1"}
}
}


def test_name(ucs_resource, ucs_host):
name, _, _ = ucs_host(ucs_resource, '')
assert name == 'control-0.mydomain.com'


@pytest.mark.parametrize('attr,should', {
'ansible_ssh_host': '10.30.0.172',
'role': 'control',
'consul_dc': 'root',
'provider': 'ucs',
'public_ipv4': '10.30.0.172',
'private_ipv4': '10.30.0.172',
'consul_is_server': True,
'metadata':
{'role': 'control', },
}.items())
def test_attrs(ucs_resource, ucs_host, attr, should):
_, attrs, _ = ucs_host(ucs_resource, 'root')
assert attr in attrs
assert attrs[attr] == should

@pytest.mark.parametrize('group', [
'role=control',
'dc=root',
])
def test_groups(ucs_resource, ucs_host, group):
_, _, groups = ucs_host(ucs_resource, 'root')
assert group in groups

0 comments on commit 71f5408

Please sign in to comment.