'Tests the test_convert_mapping_to_xml_fail_required function'

def test_convert_mapping_to_xml(self):

    default_root = XML.Element('testdefault')
    default_data = yaml.load('string:    hello')
    default_mappings = [('default-string', 'defaultString', 'default')]
    convert_mapping_to_xml(default_root, default_data, default_mappings, fail_required=True)
    result = default_root.find('defaultString').text
    self.assertThat(result, Equals('default'))
    user_input_root = XML.Element('testUserInput')
    user_input_data = yaml.load('user-input-string:    hello')
    user_input_mappings = [('user-input-string', 'userInputString', 'user-input')]
    convert_mapping_to_xml(user_input_root, user_input_data, user_input_mappings, fail_required=True)
    result = user_input_root.find('userInputString').text
    self.assertThat(result, Equals('hello'))
    required_root = XML.Element('testrequired')
    required_data = yaml.load('string:    hello')
    required_mappings = [('required-string', 'requiredString', None)]
    self.assertRaises(MissingAttributeError, convert_mapping_to_xml, required_root, required_data, required_mappings, fail_required=True)
    user_input_root = XML.Element('testUserInput')
    user_input_data = yaml.load('user-input-string:    bye')
    valid_inputs = ['hello']
    user_input_mappings = [('user-input-string', 'userInputString', 'user-input', valid_inputs)]
    self.assertRaises(InvalidAttributeError, convert_mapping_to_xml, user_input_root, user_input_data, user_input_mappings)
    user_input_root = XML.Element('testUserInput')
    user_input_data = yaml.load('user-input-string:    later')
    valid_inputs = {'hello': 'world'}
    user_input_mappings = [('user-input-string', 'userInputString', 'user-input', valid_inputs)]
    self.assertRaises(InvalidAttributeError, convert_mapping_to_xml, user_input_root, user_input_data, user_input_mappings)
    user_input_root = XML.Element('testUserInput')
    user_input_data = yaml.load('user-input-string:    world')
    valid_inputs = {'hello': 'world'}
    user_input_mappings = [('user-input-string', 'userInputString', 'user-input', valid_inputs)]
    self.assertRaises(InvalidAttributeError, convert_mapping_to_xml, user_input_root, user_input_data, user_input_mappings)
