prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Model up yaml configs from the DB
  Various yaml configs are stored in the database, including the one we'll most likely want to imspect, which is the vmdb config.
  
  The schema, for our purposes, is two fields in the `configurations` table, `typ` and `settings`. The interface that I'm leaning toward is configurations[typ] = dictified_yaml(settings), if that makes sense. 
  
  So, for example, if we wanted to see whether or not to get a list of public images from ec2, the lookup would be `configurations['vmdb']['ems_refresh']['ec2']['get_public_images']`
  
  
  </issue>
  <code>
  [start of fixtures/cfmedb.py]
  1 '''
  2 
  3 
  4 Created on Jun 14, 2013
  5 
  6 @author: bcrochet
  7 
  8 '''
  9 # -*- coding: utf-8 -*-
  10 # pylint: disable=C0103
  11 # pylint: disable=E1101
  12 import pytest
  13 from urlparse import urlparse
  14 from sqlalchemy import create_engine
  15 from sqlalchemy.orm import sessionmaker
  16 import ConfigParser
  17 
  18 def pytest_addoption(parser):
  19     '''Create the options for py.test'''
  20     config = ConfigParser.ConfigParser(defaults={
  21         'cfmedburl': ''
  22     })
  23     config.read('cfme.cfg')
  24 
  25     group = parser.getgroup('cfme', 'cfme')
  26     group.addoption('--cfmedburl',
  27                      action='store',
  28                      dest='cfme_db_url',
  29                      default=config.get('DEFAULT', 'cfmedburl'),
  30                      metavar='url',
  31                      help='url for CFME database to connect to')
  32 
  33 def pytest_sessionstart(session):
  34     '''Setup run for tests'''
  35     import db
  36     db.cfme_db_url = session.config.option.cfme_db_url
  37     if not db.cfme_db_url:
  38         # Let's try to figure it out
  39         baseurl = session.config.option.base_url
  40         baseip = urlparse(baseurl).hostname
  41         db.cfme_db_url = "postgres://root:smartvm@%s:5432/vmdb_production" \
  42                 % baseip
  43     db.engine = create_engine(db.cfme_db_url)
  44 
  45 @pytest.fixture
  46 def db_session():
  47     '''Creates a database session based on the db url passed on the CLI
  48 
  49     Usage example:
  50 
  51     This is a SQLalchemy (http://www.sqlalchemy.org/) session. You can make
  52     queries and create new rows in the database with this session.
  53 
  54     The available classes are dynamically generated from the database. Consult
  55     db/__init__.py for a list of available class -> table mappings.
  56 
  57     An example test:
  58 
  59     @pytest.mark.nondestructive
  60     def test_that_tries_for_db(db_session):
  61         import db
  62         session = db_session
  63         for instance in session.query(db.ExtManagementSystem).order_by(
  64             db.ExtManagementSystem.id):
  65         print instance.name, instance.hostname
  66 
  67     This 'test' prints the management systems from the database.
  68     '''
  69     import db
  70     Session = sessionmaker(bind=db.engine)
  71     return Session()
  72 
  73
  [end of fixtures/cfmedb.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/fixtures/cfmedb.py b/fixtures/cfmedb.py
  --- a/fixtures/cfmedb.py
  +++ b/fixtures/cfmedb.py
  @@ -70,3 +70,13 @@
       Session = sessionmaker(bind=db.engine)
       return Session()
   
  +@pytest.fixture
  +def db_yamls(db_session):
  +    '''Returns the yamls from the db configuration table as a dict'''
  +
  +    import db
  +    import yaml
  +    configs = db_session.query(db.Configuration.typ, db.Configuration.settings)
  +    data = {name: yaml.load(settings) for name, settings in configs}
  +
  +    return data
  
verification_info: {"golden_diff": "diff --git a/fixtures/cfmedb.py b/fixtures/cfmedb.py\n--- a/fixtures/cfmedb.py\n+++ b/fixtures/cfmedb.py\n@@ -70,3 +70,13 @@\n     Session = sessionmaker(bind=db.engine)\n     return Session()\n \n+@pytest.fixture\n+def db_yamls(db_session):\n+    '''Returns the yamls from the db configuration table as a dict'''\n+\n+    import db\n+    import yaml\n+    configs = db_session.query(db.Configuration.typ, db.Configuration.settings)\n+    data = {name: yaml.load(settings) for name, settings in configs}\n+\n+    return data\n", "issue": "Model up yaml configs from the DB\nVarious yaml configs are stored in the database, including the one we'll most likely want to imspect, which is the vmdb config.\n\nThe schema, for our purposes, is two fields in the `configurations` table, `typ` and `settings`. The interface that I'm leaning toward is configurations[typ] = dictified_yaml(settings), if that makes sense. \n\nSo, for example, if we wanted to see whether or not to get a list of public images from ec2, the lookup would be `configurations['vmdb']['ems_refresh']['ec2']['get_public_images']`\n\n", "before_files": [{"content": "'''\n\n\nCreated on Jun 14, 2013\n\n@author: bcrochet\n\n'''\n# -*- coding: utf-8 -*-\n# pylint: disable=C0103\n# pylint: disable=E1101\nimport pytest\nfrom urlparse import urlparse\nfrom sqlalchemy import create_engine\nfrom sqlalchemy.orm import sessionmaker\nimport ConfigParser\n\ndef pytest_addoption(parser):\n    '''Create the options for py.test'''\n    config = ConfigParser.ConfigParser(defaults={\n        'cfmedburl': ''\n    })\n    config.read('cfme.cfg')\n\n    group = parser.getgroup('cfme', 'cfme')\n    group.addoption('--cfmedburl',\n                     action='store',\n                     dest='cfme_db_url',\n                     default=config.get('DEFAULT', 'cfmedburl'),\n                     metavar='url',\n                     help='url for CFME database to connect to')\n\ndef pytest_sessionstart(session):\n    '''Setup run for tests'''\n    import db\n    db.cfme_db_url = session.config.option.cfme_db_url\n    if not db.cfme_db_url:\n        # Let's try to figure it out\n        baseurl = session.config.option.base_url\n        baseip = urlparse(baseurl).hostname\n        db.cfme_db_url = \"postgres://root:smartvm@%s:5432/vmdb_production\" \\\n                % baseip\n    db.engine = create_engine(db.cfme_db_url)\n\n@pytest.fixture\ndef db_session():\n    '''Creates a database session based on the db url passed on the CLI\n\n    Usage example:\n\n    This is a SQLalchemy (http://www.sqlalchemy.org/) session. You can make\n    queries and create new rows in the database with this session.\n\n    The available classes are dynamically generated from the database. Consult\n    db/__init__.py for a list of available class -> table mappings.\n\n    An example test:\n\n    @pytest.mark.nondestructive\n    def test_that_tries_for_db(db_session):\n        import db\n        session = db_session\n        for instance in session.query(db.ExtManagementSystem).order_by(\n            db.ExtManagementSystem.id):\n        print instance.name, instance.hostname\n\n    This 'test' prints the management systems from the database.\n    '''\n    import db\n    Session = sessionmaker(bind=db.engine)\n    return Session()\n\n", "path": "fixtures/cfmedb.py"}]}