Пример #1
0
    def test_stupid(self):

        qp = QueryProperty(db, Vehicle)

        class Dummy(object):
            vehicles = qp

        qp.model = object

        self.assertIsNone(Dummy.vehicles)
Пример #2
0
    def test_bad_attr(self):

        with self.assertRaises(AttributeError) as ctx:
            QueryProperty(db, Vehicle).dummy(db.joinedload(Vehicle.owner))

        self.assertEqual(
            ctx.exception.args,
            (
                "<QueryProperty db=<SQLAlchemy engine=postgresql://postgres@localhost/test>, model='Vehicle'> object has no attribute 'dummy'",
            ),
        )
Пример #3
0
    def test_bad_attr(self):

        with self.assertRaises(AttributeError) as ctx:
            QueryProperty(db, Vehicle).dummy(db.joinedload(Vehicle.owner))

        self.assertEqual(
            ctx.exception.args,
            (f"<QueryProperty db=<SQLAlchemy engine=postgresql://postgres:***@{settings.DB_URL.host}/test>, "
             "model='Vehicle'> "
             "object has no attribute 'dummy'", ),
        )
Пример #4
0
 class Dummy(object):
     vehicles = QueryProperty(db, None)
Пример #5
0
 class Dummy(object):
     vehicles = QueryProperty(db, Vehicle).options(db.joinedload(Vehicle.owner))
     used_vehicles = QueryProperty(db, Vehicle, Vehicle.is_used.is_(True))
     new_vehicles = QueryProperty(db, Vehicle, is_used=False)
Пример #6
0
 class Dummy:
     vehicles = QueryProperty(db, None)