Add units tests to jjos branch

This commit is contained in:
Liam Young 2015-09-28 08:59:49 +00:00
parent cfb373c847
commit 77e62ce783
2 changed files with 42 additions and 1 deletions

View File

@ -4,7 +4,7 @@ summary: "Openstack nova controller node."
description: |
Cloud controller node for Openstack nova. Contains nova-schedule,
nova-api, nova-network and nova-objectstore.
categories:
tags:
- openstack
provides:
nrpe-external-master:

View File

@ -19,6 +19,7 @@ from charmhelpers.contrib.openstack import utils
from test_utils import CharmTestCase
from charmhelpers.contrib.openstack import neutron
TO_PATCH = [
'apt_install',
@ -30,6 +31,7 @@ TO_PATCH = [
'log',
'relations_for_id',
'https',
'is_relation_made',
]
@ -148,3 +150,42 @@ class NovaComputeContextTests(CharmTestCase):
self.assertTrue(context.use_local_neutron_api())
self.related_units.return_value = ['unit/0']
self.assertFalse(context.use_local_neutron_api())
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_address_in_network')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_netmask_for_address')
@mock.patch('charmhelpers.contrib.openstack.context.local_unit')
@mock.patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
@mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr,
mock_local_unit, mock_get_netmask_for_address,
mock_get_address_in_network, mock_https,
mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
self.is_relation_made.return_value = False
ctxt = context.HAProxyContext()()
self.assertEqual(ctxt['service_ports']['neutron-server'], [9696, 9686])
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_address_in_network')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_netmask_for_address')
@mock.patch('charmhelpers.contrib.openstack.context.local_unit')
@mock.patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
@mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
def test_haproxy_context_api_relation(self, mock_relation_ids,
mock_get_ipv6_addr, mock_local_unit,
mock_get_netmask_for_address,
mock_get_address_in_network,
mock_https, mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
self.is_relation_made.return_value = True
ctxt = context.HAProxyContext()()
self.assertEqual(ctxt['service_ports'].get('neutron-server'), None)