示例#1
0
def test_can_be_named_by_binding():
    table = Fake()
    column = Column()

    column.bind_to(table, "epsilon")

    assert column.name == "epsilon"
示例#2
0
def test_can_be_named_by_binding():
    table = Fake()
    column = Column()

    column.bind_to(table, "epsilon")

    assert column.name == "epsilon"
示例#3
0
def test_raises_if_rebound():
    table_a = Fake()
    table_b = Fake()
    column = Column()

    column.bind_to(table_a, "beta")

    assert_raises(AttributeError, column.bind_to, table_b, "gamma")
示例#4
0
def test_can_be_bound():
    table = Fake()
    column = Column()

    column.bind_to(table, "alpha")

    assert column.is_bound == True
    assert column.bound_to == (table, "alpha")
示例#5
0
def test_raises_if_rebound():
    table_a = Fake()
    table_b = Fake()
    column = Column()

    column.bind_to(table_a, "beta")

    assert_raises(AttributeError, column.bind_to, table_b, "gamma")
示例#6
0
def test_can_be_bound():
    table = Fake()
    column = Column()

    column.bind_to(table, "alpha")

    assert column.is_bound == True
    assert column.bound_to == (table, "alpha")
示例#7
0
def test_can_specify_css_class():
    column_with_css = Column(css_class="rho")
    column_no_css = Column()

    assert column_with_css.has_css_class == True
    assert column_with_css.css_class == "rho"

    assert column_no_css.has_css_class == False
    assert column_no_css.css_class == None
示例#8
0
def test_can_link():
    cell = Fake().has_attr(value="xxx")
    linked_column = Column(link=lambda cell: cell.value.upper())
    unlinked_column = Column()

    assert linked_column.has_link == True
    assert linked_column.link(cell) == u"XXX"

    assert unlinked_column.has_link == False
    assert unlinked_column.link(cell) == None
示例#9
0
def test_can_link():
    cell = Fake().has_attr(value="pi")
    linked_column = Column(link=lambda cell: cell.value.upper())
    unlinked_column = Column()

    assert linked_column.has_link == True
    assert linked_column.link(cell) == u"PI"

    assert unlinked_column.has_link == False
    assert unlinked_column.link(cell) == None
示例#10
0
def test_value_can_be_wrapped():
    cell = Fake().has_attr(value="abc")
    column = Column(value=lambda cell: cell.value.upper())
    assert column.render(cell) == u"ABC"
示例#11
0
def test_sortable_by_order_of_creation():
    a, b, c = Column(), Column(), Column()
    assert sorted([b, a, c]) == [a, b, c]
示例#12
0
def test_renders_name_to_unicode():
    assert unicode(Column('zeta')) == u"zeta"
示例#13
0
def test_value_can_be_wrapped():
    cell = Fake().has_attr(value="abc")
    column = Column(value=lambda cell: cell.value.upper())
    assert column.render(cell) == u"ABC"
示例#14
0
def test_renders_values_to_unicode():
    bool_cell = Fake().has_attr(value=True)
    int_cell = Fake().has_attr(value=123)

    assert Column().render(bool_cell) == u"True"
    assert Column().render(int_cell) == u"123"
示例#15
0
def test_can_be_explicitly_named():
    column = Column(name="delta")
    assert column.name == "delta"
示例#16
0
class TestTable(Table):
    name   = Column()
    weapon = Column()