'Tests that a URL with special characters, like in the credentials,
is handled properly.'

@ddt.data('mysql+pymysql://nova:abcd0123:AB@controller/%s', 'mysql+pymysql://nova:abcd0123?AB@controller/%s', 'mysql+pymysql://nova:abcd0123@AB@controller/%s', 'mysql+pymysql://nova:abcd0123/AB@controller/%s', 'mysql+pymysql://test:abcd0123/AB@controller/%s?charset=utf8')
def test_map_cell0_default_database_special_characters(self, connection):

    decoded_connection = (connection % 'nova')
    self.flags(connection=decoded_connection, group='database')
    ctxt = context.RequestContext()
    self.commands.map_cell0()
    cell_mapping = objects.CellMapping.get_by_uuid(ctxt, objects.CellMapping.CELL0_UUID)
    self.assertEqual('cell0', cell_mapping.name)
    self.assertEqual('none:///', cell_mapping.transport_url)
    self.assertEqual((connection % 'nova_cell0'), cell_mapping.database_connection)
    cell_mapping.destroy()
