def test_get_subnets_not_set(self, m_get_subnet): service = mock.sentinel.service project_id = mock.sentinel.project_id driver = default_subnet.DefaultPodSubnetDriver() self.assertRaises(cfg.RequiredOptError, driver.get_subnets, service, project_id) m_get_subnet.assert_not_called()
def test_get_subnets_not_set(self, m_get_subnet): pod = mock.sentinel.pod project_id = mock.sentinel.project_id driver = default_subnet.DefaultPodSubnetDriver() msg = ("value required for option pod_subnet in group" + " \[neutron_defaults\]") self.assertRaisesRegex(cfg.RequiredOptError, msg, driver.get_subnets, pod, project_id) m_get_subnet.assert_not_called()
def test_get_subnets(self, m_cfg, m_get_subnet): subnet_id = mock.sentinel.subnet_id subnet = mock.sentinel.subnet pod = mock.sentinel.pod project_id = mock.sentinel.project_id m_cfg.neutron_defaults.pod_subnet = subnet_id m_get_subnet.return_value = subnet driver = default_subnet.DefaultPodSubnetDriver() subnets = driver.get_subnets(pod, project_id) self.assertEqual({subnet_id: subnet}, subnets) m_get_subnet.assert_called_once_with(subnet_id)