Ejemplo n.º 1
0
    def test__get_validated_flavor_from_context_failed(self, mock_transform):
        clients = mock.MagicMock()
        clients.nova().flavors.get.side_effect = nova_exc.NotFound("")
        config = {
            "args": {
                "flavor": {
                    "name": "test"
                }
            },
            "context": {
                "flavors": [{
                    "name": "othername",
                    "ram": 32,
                }]
            }
        }
        result = validation._get_validated_flavor(config, clients, "flavor")
        self.assertFalse(result[0].is_valid, result[0].msg)

        config = {
            "args": {
                "flavor": {
                    "name": "test"
                }
            },
        }
        result = validation._get_validated_flavor(config, clients, "flavor")
        self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 2
0
 def test__get_validated_flavor_not_found(
         self, mock_flavor_resource_type_transform):
     clients = mock.MagicMock()
     clients.nova().flavors.get.side_effect = nova_exc.NotFound("")
     result = validation._get_validated_flavor({"args": {"a": "test"}},
                                               clients, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 3
0
 def test__get_validated_flavor_not_found(self, mock_transform):
     clients = mock.MagicMock()
     clients.nova().flavors.get.side_effect = nova_exc.NotFound("")
     result = validation._get_validated_flavor({"args": {
         "a": "test"
     }}, clients, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 4
0
    def test__get_validated_flavor_from_context_failed(self, mock_transform):
        clients = mock.MagicMock()
        clients.nova().flavors.get.side_effect = nova_exc.NotFound("")
        config = {
            "args": {"flavor": {"name": "test"}},
            "context": {
                "flavors": [{
                    "name": "othername",
                    "ram": 32,
                }]
            }
        }
        result = validation._get_validated_flavor(config, clients, "flavor")
        self.assertFalse(result[0].is_valid, result[0].msg)

        config = {
            "args": {"flavor": {"name": "test"}},
        }
        result = validation._get_validated_flavor(config, clients, "flavor")
        self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 5
0
    def test__get_validated_flavor(
            self, mock_flavor_resource_type_transform):
        clients = mock.MagicMock()
        clients.nova().flavors.get.return_value = "flavor"

        result = validation._get_validated_flavor({"args": {"a": "test"}},
                                                  clients, "a")
        self.assertTrue(result[0].is_valid, result[0].msg)
        self.assertEqual(result[1], "flavor")
        mock_flavor_resource_type_transform.assert_called_once_with(
            clients=clients, resource_config="test")
        clients.nova().flavors.get.assert_called_once_with(flavor="flavor_id")
Ejemplo n.º 6
0
    def test__get_validated_flavor(self, mock_transform):
        mock_transform.return_value = "flavor_id"
        clients = mock.MagicMock()
        clients.nova().flavors.get.return_value = "flavor"

        result = validation._get_validated_flavor({"args": {"a": "test"}},
                                                  clients, "a")
        self.assertTrue(result[0].is_valid, result[0].msg)
        self.assertEqual(result[1], "flavor")
        mock_transform.assert_called_once_with(clients=clients,
                                               resource_config="test")
        clients.nova().flavors.get.assert_called_once_with(flavor="flavor_id")
Ejemplo n.º 7
0
 def test__get_validated_flavor_transform_error(
         self, mock_flavor_resource_type_transform):
     result = validation._get_validated_flavor({"args": {"a": "test"}},
                                               None, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 8
0
 def test__get_validated_flavor_no_value_in_config(self):
     result = validation._get_validated_flavor({}, None, "non_existing")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 9
0
 def test__get_validated_flavor_transform_error(self, mock_transform):
     mock_transform.side_effect = exceptions.InvalidScenarioArgument
     result = validation._get_validated_flavor({"args": {
         "a": "test"
     }}, None, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 10
0
 def test__get_validated_flavor_no_value_in_config(self):
     result = validation._get_validated_flavor({}, None, "non_existing")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 11
0
 def test__get_validated_flavor_transform_error(self, mock_transform):
     mock_transform.side_effect = exceptions.InvalidScenarioArgument
     result = validation._get_validated_flavor({"args": {"a": "test"}},
                                               None, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)
Ejemplo n.º 12
0
 def test__get_validated_flavor_transform_error(
         self, mock_flavor_resource_type_transform):
     result = validation._get_validated_flavor({"args": {
         "a": "test"
     }}, None, "a")
     self.assertFalse(result[0].is_valid, result[0].msg)