Exemple #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']")
Exemple #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)
Exemple #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)
Exemple #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']")