def test_validate_variable_type_invalid_value(self): """Test validate variable type invalid value.""" with self.assertRaises(ValueError): var_name = "testVar" var_type = int provided_value = "abc" validate_variable_type(var_name, var_type, provided_value)
def test_validate_variable_type_cfntype_none_value(self): """Test validate variable type cfntype none value.""" with self.assertRaises(ValueError): var_name = "testVar" var_type = CFNString provided_value = None validate_variable_type(var_name, var_type, provided_value)
def test_strict_validate_variable_type(self): """Test strict validate variable type.""" with self.assertRaises(ValueError): var_name = "testVar" var_type = int provided_value = "1" validate_variable_type(var_name, var_type, provided_value)
def test_validate_variable_type_troposphere(mocker: MockerFixture) -> None: """Test validate_variable_type.""" mock_create = mocker.patch.object( TroposphereType, "create", side_effect=["success", Exception] ) value = {"Endpoint": "test", "Protocol": "test"} assert ( validate_variable_type("test", TroposphereType(sns.Subscription), value) == "success" ) mock_create.assert_called_once_with(value) with pytest.raises(ValidatorError): validate_variable_type("test", TroposphereType(sns.Subscription), value)
def test_validate_variable_type_matching_type(self): """Test validate variable type matching type.""" var_name = "testVar" var_type = str provided_value = "abc" value = validate_variable_type(var_name, var_type, provided_value) self.assertEqual(value, provided_value)
def test_validate_variable_type_cfntype(self): """Test validate variable type cfntype.""" var_name = "testVar" var_type = CFNString provided_value = "abc" value = validate_variable_type(var_name, var_type, provided_value) self.assertIsInstance(value, CFNParameter)
def test_validate_variable_type_python_raise_type_error() -> None: """Test validate_variable_type.""" with pytest.raises(TypeError): validate_variable_type("name", int, "0")
def test_validate_variable_type_python() -> None: """Test validate_variable_type.""" assert validate_variable_type("name", str, "test") == "test"
def test_validate_variable_type_cfn_raise_type_error() -> None: """Test validate_variable_type.""" with pytest.raises(TypeError): validate_variable_type("name", CFNString, None)
def test_validate_variable_type_cfn() -> None: """Test validate_variable_type.""" result = validate_variable_type("name", CFNString, "test") assert isinstance(result, CFNParameter) assert result.name == "name" assert result.value == "test"