Beispiel #1
0
    def test_network_exists_fail(self, mock_osclients):
        fakenclient = fakes.FakeNovaClient()
        fake_network = fakes.FakeNetwork()
        fake_network.label = "private"
        fake_network.id = "net_id_1234"

        fakenclient.networks.list = mock.MagicMock(return_value=[fake_network])
        mock_osclients.nova.return_value = fakenclient

        validator = validation.network_exists("fixed_network")

        network_name = "foo"

        result = validator(clients=mock_osclients, fixed_network=network_name)

        fakenclient.networks.list.assert_called_once_with()
        self.assertFalse(result.is_valid)
        self.assertEqual(result.msg, "Network with name foo not found. " "Available networks: ['private']")
Beispiel #2
0
    def test_network_exists(self, mock_osclients):
        fakenclient = fakes.FakeNovaClient()
        fake_network = fakes.FakeNetwork()
        fake_network.label = "private"
        fake_network.id = "net_id_1234"

        fakenclient.networks.list = mock.MagicMock(return_value=[fake_network])
        mock_osclients.nova.return_value = fakenclient

        validator = validation.network_exists("fixed_network")

        network_name = "private"

        result = validator(clients=mock_osclients, fixed_network=network_name)

        fakenclient.networks.list.assert_called_once_with()
        self.assertTrue(result.is_valid)
        self.assertIsNone(result.msg)
Beispiel #3
0
    def test_network_exists(self, mock_osclients):
        fakenclient = fakes.FakeNovaClient()
        fake_network = fakes.FakeNetwork()
        fake_network.label = "private"
        fake_network.id = "net_id_1234"

        fakenclient.networks.list = mock.MagicMock(return_value=[fake_network])
        mock_osclients.nova.return_value = fakenclient

        validator = validation.network_exists("fixed_network")

        network_name = "private"

        config = {"args": {"fixed_network": network_name}}
        result = validator(config, clients=mock_osclients, task=None)

        fakenclient.networks.list.assert_called_once_with()
        self.assertTrue(result.is_valid)
        self.assertIsNone(result.msg)
Beispiel #4
0
    def test_network_exists_fail(self, mock_osclients):
        fakenclient = fakes.FakeNovaClient()
        fake_network = fakes.FakeNetwork()
        fake_network.label = "private"
        fake_network.id = "net_id_1234"

        fakenclient.networks.list = mock.MagicMock(return_value=[fake_network])
        mock_osclients.nova.return_value = fakenclient

        validator = validation.network_exists("fixed_network")

        network_name = "foo"

        config = {"args": {"fixed_network": network_name}}
        result = validator(config, clients=mock_osclients, task=None)

        fakenclient.networks.list.assert_called_once_with()
        self.assertFalse(result.is_valid)
        self.assertEqual(
            result.msg, "Network with name foo not found. "
            "Available networks: ['private']")