Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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")
Beispiel #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")
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)