当前位置: 首页>>代码示例>>Python>>正文


Python Session.query方法代码示例

本文整理汇总了Python中tests.run.Session.query方法的典型用法代码示例。如果您正苦于以下问题:Python Session.query方法的具体用法?Python Session.query怎么用?Python Session.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tests.run.Session的用法示例。


在下文中一共展示了Session.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_del_sts_from_vehicle

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_del_sts_from_vehicle(self):

        self.session.add(self.u1)
        self.session.add(self.v1)

        data = server.addSTS(self.u1.id, self.v1.id, "111222", "Ф666МИ")

        self.assertJsonRpc(data)
        self.assertIs(data['result'], True)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        v = s.query(TrVehicle).get(self.v1.id)
        self.assertIsNotNone(v)
        self.assertEquals(v.id, self.v1.id)
        self.assertEquals(v.car_sts, u'111222')
        self.assertEquals(v.car_number, u'Ф666МИ')
        s.close()

        data = server.delSTS(self.u1.id, self.v1.id)

        self.assertJsonRpc(data)
        self.assertIs(data['result'], True)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        v = s.query(TrVehicle).get(self.v1.id)
        self.assertIsNotNone(v)
        self.assertEquals(v.id, self.v1.id)
        self.assertIsNone(v.car_sts)
        self.assertIsNone(v.car_number)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:34,代码来源:vehicle.py

示例2: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        map(session.delete, users)

        places = session.query(TrPlace).all()
        map(session.delete, places)

        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:place.py

示例3: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        map(session.delete, users)

        groups = session.query(TrGroup).all()
        map(session.delete, groups)

        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:group.py

示例4: tearDownClass

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def tearDownClass(cls):

        session = Session()

        users = session.query(TrUser).all()
        for user in users:
            session.delete(user)
        session.commit()

        devices = session.query(TrDevice).all()
        for d in devices:
            session.delete(d)
        session.commit()

        session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:17,代码来源:device.py

示例5: test_delete_geo

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_delete_geo(self):

        data = server.delDGeo(user_id=self.u1.ID, id=self.d1.geos[0].id)
        gid = self.d1.geos[0].id
        self.assertJsonRpc(data)
        self.assertEquals(data['result'], True)

        s = Session()
        d = s.query(TrDevice).get(self.d1.device_ID)
        self.assertEqual(len(d.geos), 0)
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:12,代码来源:geo.py

示例6: test_unreg_normal

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_unreg_normal(self):

        self.session.add(self.u1)
        self.session.add(self.v1)
        self.session.add(self.d1)

        data = server.unregDevice(user_id=self.u1.id, vehicle_id=self.v1.id, device_id=self.d1.id)

        self.assertJsonRpc(data)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        v = s.query(TrVehicle).get(self.v1.id)
        self.assertIsNotNone(v)
        self.assertEquals(v.id, self.v1.id)
        self.assertIsNone(v.device)

        d = s.query(TrDevice).get(self.d1.id)
        self.assertIsNotNone(d)
        self.assertEquals(d.id, self.d1.id)
        self.assertEquals(d.stat, False)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:24,代码来源:device.py

示例7: test_add_group

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_group(self):

        self.session.add(self.u1)
        data = server.addGroup(self.u1.id, "group", "desc", True, False, False)

        self.assertJsonRpc(data)
        self.assertIs(type(data['result']), int)

        s = Session()
        g = s.query(TrGroup).get(data['result'])
        self.assertEquals(g.title, u'group')
        self.assertEquals(g.desc, u'desc')
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:15,代码来源:group.py

示例8: test_add_without_desc

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_without_desc(self):

        self.session.add(self.u1)

        data = server.addPlace(user_id=self.u1.id, title="TestAddTitle", longitude="77.7777", latitude="11.1111", type="cafe", desc="")

        self.assertIn(u'result', data)
        id = data['result']

        s = Session()
        ps = s.query(TrPlace).get(id)
        self.assertEquals(ps.title, u'TestAddTitle')
        self.assertAlmostEqual(float(ps.longitude), 77.7777)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:16,代码来源:place.py

示例9: test_add_new_vehicle_cyrillic_name

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_new_vehicle_cyrillic_name(self):

        self.session.add(self.u1)

        data = server.addVehicle(self.u1.id, "Машина", "A", "BMW", u'3 серия', u'E30 [рестайлинг] Touring универсал', "316i AT", 1992)

        self.assertJsonRpc(data)
        self.assertIs(type(data['result']), int)
        id = data['result']

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        v = s.query(TrVehicle).get(id)
        self.assertEquals(v.name, u'Машина')
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:17,代码来源:vehicle.py

示例10: test_add_new_vehicle

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_new_vehicle(self):

        self.session.add(self.u1)

        data = server.addVehicle(self.u1.id, "Test", "A", "BMW", u'3 серия', u'E30 [рестайлинг] Touring универсал', "316i AT", 1992)

        self.assertJsonRpc(data)
        self.assertIs(type(data['result']), int)
        id = data['result']

        s = Session()
        v = s.query(TrVehicle).get(id)
        self.assertEquals(v.name, u'Test')
        self.assertEquals(v.year, 1992)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:17,代码来源:vehicle.py

示例11: test_update_geo_state

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_update_geo_state(self):

        self.session.add_all([self.u1, self.u2])
        self.session.add_all([self.d1, self.d2])

        data = server.updateDGeo(user_id=self.u1.ID, id=self.d1.geos[0].id, state=False)

        self.assertJsonRpc(data)
        self.assertEquals(data['result'], True)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        g = s.query(TrDGeozone).get(self.d1.geos[0].id)
        self.assertEquals(g.state, False)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:17,代码来源:geo.py

示例12: test_delete_one_own_group

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_delete_one_own_group(self):

        self.session.add(self.u1)
        self.session.add(self.g1)

        data = server.delGroup(self.u1.id, self.g1.id)

        self.assertJsonRpc(data)
        self.assertIs(data['result'], True)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        g = s.query(TrGroup).get(self.g1.id)
        self.assertIsNone(g)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:17,代码来源:group.py

示例13: test_delete_normal

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_delete_normal(self):

        self.session.add(self.u1)
        self.session.add(self.v1)
        self.session.add(self.d1)

        data = server.delDevice(self.u1.id, self.d1.id)

        self.assertJsonRpc(data)

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        v = s.query(TrVehicle).get(self.v1.id)
        self.assertIsNotNone(v)
        self.assertIsNone(v.device)
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:18,代码来源:device.py

示例14: test_add_normal_place

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_normal_place(self):

        self.session.add(self.u1)

        data = server.addPlace(self.u1.id, "TestAddTitle", "77.7777", "11.1111", "cafe", "Description")

        self.assertIn(u'result', data)
        id = data['result']

        """ Separate session, cause cross-session's transaction collision """
        s = Session()
        ps = s.query(TrPlace).get(id)
        self.assertEquals(ps.title, "TestAddTitle")
        self.assertAlmostEqual(float(ps.longitude), 77.7777)
        self.assertEquals(ps.desc, "Description")
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:18,代码来源:place.py

示例15: test_add_notmal_meeting

# 需要导入模块: from tests.run import Session [as 别名]
# 或者: from tests.run.Session import query [as 别名]
    def test_add_notmal_meeting(self):

        self.session.add(self.u1)
        self.session.add(self.g1)

        data = server.addGroupMeeting(self.u1.id, self.g1.id, "t1", "54.123,35.333", 123456789)

        self.assertJsonRpc(data)
        self.assertIn(u'result', data)
        self.assertIs(type(data['result']), int)

        s = Session()
        g = s.query(TrGroup).get(self.g1.id)
        self.assertEquals(len(g.meetings), 1)
        self.assertEquals(g.meetings[0].id, data['result'])
        self.assertEquals(g.meetings[0].title, u't1')
        s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:19,代码来源:group.py


注:本文中的tests.run.Session.query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。