def test_basic(self):
        class Address(Entity):
            street = Field(String(130))
            city = Field(String(100))
            using_options(shortnames=True)

        class Comment(Entity):
            id = Field(Integer, primary_key=True)
            name = Field(String(200))
            text = Field(Text)

        is_addressable = associable(Address, 'addresses')
        is_commentable = associable(Comment, 'comments')

        class Person(Entity):
            id = Field(Integer, primary_key=True)
            name = Field(String(50))
            orders = OneToMany('Order')
            using_options(shortnames=True)
            is_addressable()
            is_commentable()

        class Order(Entity):
            order_num = Field(Integer, primary_key=True)
            item_count = Field(Integer)
            person = ManyToOne('Person')
            using_options(shortnames=True)
            is_addressable('address', uselist=False)

        setup_all(True)

        home = Address(street='123 Elm St.', city='Spooksville')
        work = Address(street='243 Hooper st.', city='Cupertino')
        user = Person(name='Jane Doe')
        user.addresses.append(home)
        user.addresses.append(work)

        neworder = Order(item_count=4)
        neworder.address = home
        user.orders.append(neworder)

        session.commit()
        session.expunge_all()

        # Queries using the added helpers
        people = Person.select_by_addresses(city='Cupertino')
        assert len(people) == 1

        streets = [adr.street for adr in people[0].addresses]
        assert '243 Hooper st.' in streets
        assert '123 Elm St.' in streets

        people = Person.select_addresses(and_(Address.street=='132 Elm St',
                                              Address.city=='Smallville'))
        assert len(people) == 0
dataset/ETHPy150Open jmg/elixir/tests/test_associable.py/TestOrders.test_basic/original