# -*- coding: utf-8 -*-
from formalchemy.tests import *

def test_dropdown():
    """
    >>> fs = FieldSet(bill)
    >>> print pretty_html(fs.orders.render())
    <select id="User-1-orders" multiple="multiple" name="User-1-orders" size="5">
     <option value="2">
      Quantity: 5
     </option>
     <option value="3">
      Quantity: 6
     </option>
     <option value="1" selected="selected">
      Quantity: 10
     </option>
    </select>
    """

def test_lazy_filtered_dropdown():
    """
    >>> fs = FieldSet(bill)
    >>> def available_orders(fs_):
    ...     return fs_.session.query(Order).filter_by(quantity=10)
    >>> fs.configure(include=[fs.orders.dropdown(options=available_orders)])
    >>> print pretty_html(fs.orders.render())
    <select id="User-1-orders" multiple="multiple" name="User-1-orders" size="5">
     <option value="1" selected="selected">
      Quantity: 10
     </option>
    </select>
    """

@@ -908,28 +908,616 @@
 tion%3E%0A    %3C/select%3E%0A    %22%22%22%0A
+%0Adef test_lazy_record():%0A    %22%22%22%0A    %3E%3E%3E fs = FieldSet(bill)%0A    %3E%3E%3E r = engine.execute('select quantity, user_id from orders').fetchall()%0A    %3E%3E%3E r = engine.execute(%22select 'Swedish' as name, 'sv_SE' as iso_code union all select 'English', 'en_US'%22).fetchall()%0A    %3E%3E%3E fs.configure(include=%5Bfs.orders.dropdown(options=r)%5D)%0A    %3E%3E%3E print pretty_html(fs.orders.render())%0A    %3Cselect id=%22User-1-orders%22 multiple=%22multiple%22 name=%22User-1-orders%22 size=%225%22%3E%0A     %3Coption value=%22sv_SE%22%3E%0A      Swedish%0A     %3C/option%3E%0A     %3Coption value=%22en_US%22%3E%0A      English%0A     %3C/option%3E%0A    %3C/select%3E%0A    %22%22%22%0A

add test for ResultProxy as option