Example #1
0
 def test_get_provider_for_flavor_id_flavor_disabled(self):
     FAKE_FLAVOR = {'service_type': p_constants.VPN, 'enabled': False}
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(flav_exc.FlavorDisabled,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, _uuid())
Example #2
0
 def test_get_provider_for_flavor_id_invalid_type(self):
     FAKE_FLAVOR = {'service_type': 'NOT_VPN'}
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(lib_exc.InvalidServiceType,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, _uuid())
Example #3
0
 def test_get_provider_for_flavor_id_provider_not_found(self):
     FLAVOR_ID = _uuid()
     FAKE_FLAVOR = {
         'id': FLAVOR_ID,
         'service_type': p_constants.VPN,
         'enabled': True
     }
     PROVIDERS = [{'provider': 'SOME_PROVIDER'}]
     directory.add_plugin(p_constants.FLAVORS, FlavorsPlugin())
     mock.patch(
         'neutron.services.flavors.flavors_plugin.FlavorsPlugin.get_flavor',
         return_value=FAKE_FLAVOR).start()
     mock.patch(
         'neutron.services.flavors.flavors_plugin.'
         'FlavorsPlugin.get_flavor_next_provider',
         return_value=PROVIDERS).start()
     with self.vpnservices_providers_set():
         driver_plugin = vpn_plugin.VPNDriverPlugin()
         self.assertRaises(vpn_flavors.NoProviderFoundForFlavor,
                           driver_plugin._get_provider_for_flavor,
                           self.adminContext, FLAVOR_ID)