本文整理汇总了Python中tests.run.Session类的典型用法代码示例。如果您正苦于以下问题:Python Session类的具体用法?Python Session怎么用?Python Session使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Session类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_delete_geo
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,代码行数:10,代码来源:geo.py
示例2: test_add_group
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,代码行数:13,代码来源:group.py
示例3: test_del_sts_from_vehicle
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,代码行数:32,代码来源:vehicle.py
示例4: test_add_without_desc
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,代码行数:14,代码来源:place.py
示例5: tearDownClass
def tearDownClass(cls):
session = Session()
session = Session()
users = session.query(TrUser).all()
for user in users:
session.delete(user)
session.commit()
session.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:11,代码来源:geo.py
示例6: test_add_new_vehicle_cyrillic_name
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,代码行数:15,代码来源:vehicle.py
示例7: test_add_new_vehicle
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,代码行数:15,代码来源:vehicle.py
示例8: test_delete_one_own_group
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,代码行数:15,代码来源:group.py
示例9: test_update_geo_state
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,代码行数:15,代码来源:geo.py
示例10: test_add_normal_place
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,代码行数:16,代码来源:place.py
示例11: test_delete_normal
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,代码行数:16,代码来源:device.py
示例12: test_add_notmal_meeting
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,代码行数:17,代码来源:group.py
示例13: test_delete_vehicle
def test_delete_vehicle(self):
self.session.add(self.u2)
self.session.add(self.v2)
self.session.add(self.d2)
data = server.delVehicle(self.u2.id, self.v2.id)
self.assertJsonRpc(data)
""" Separate session, cause cross-session's transaction collision """
s = Session()
d = s.query(TrDevice).get(self.d2.id)
self.assertIsNotNone(d)
self.assertEquals(d.id, self.d2.id)
self.assertEquals(d.sn, 'EW-14100002-UT')
self.assertEquals(d.stat, False)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:18,代码来源:device.py
示例14: test_update_vehicle_name_with_incorrect_model_year
def test_update_vehicle_name_with_incorrect_model_year(self):
self.session.add(self.u1)
self.session.add(self.v3)
data = server.updateVehicle(user_id=self.u1.id, id=self.v3.id, name="new_name",
maker="AC", model="Cobra", generation="1 поколение родстер",
modification="4.9 MT", year=1985)
self.assertJsonRpcErr(data)
self.assertEquals(data['error'][u'message'], "ServerError: Incorrect vehicle params.")
""" Separate session, cause cross-session's transaction collision """
s = Session()
v = s.query(TrVehicle).get(self.v3.id)
self.assertIsNotNone(v)
self.assertEquals(v.name, u'v3')
self.assertEquals(v.car_model_id, 333)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:19,代码来源:vehicle.py
示例15: test_update_vehicle_name
def test_update_vehicle_name(self):
self.session.add(self.u1)
self.session.add(self.v1)
data = server.updateVehicle(user_id=self.u1.id, id=self.v1.id, name="new_name",
maker="Alfa Romeo", model="164", generation="1 поколение седан",
modification="2.0 MT", year=1989) # car_model_id = 111
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.name, u'new_name')
self.assertEquals(v.year, 1989)
self.assertEquals(v.car_model_id, 111)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:20,代码来源:vehicle.py
示例16: test_reg_normal_device
def test_reg_normal_device(self):
self.session.add(self.u1)
self.session.add(self.v1)
self.session.add(self.d1)
data = server.regDevice(user_id=self.u1.id, vehicle_id=self.v1.id, sn='EW-14100001-UT', secret_code='sec1')
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.assertIsNotNone(v.device)
self.assertEquals(v.device.id, self.d1.id)
self.assertEquals(v.device.sn, 'EW-14100001-UT')
self.assertEquals(v.device.stat, True)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:20,代码来源:device.py
示例17: test_update_vehicle_name_and_model
def test_update_vehicle_name_and_model(self):
self.session.add(self.u1)
self.session.add(self.v2)
data = server.updateVehicle(user_id=self.u1.id, id=self.v2.id, name="new_name",
maker="AC", model="Cobra", generation="1 поколение родстер",
modification="4.9 MT", year=2000) # car_model_id = 8
self.assertJsonRpc(data)
self.assertIs(data['result'], True)
""" Separate session, cause cross-session's transaction collision """
s = Session()
v = s.query(TrVehicle).get(self.v2.id)
self.assertIsNotNone(v)
self.assertEquals(v.name, u'new_name')
self.assertEquals(v.year, 2000)
self.assertEquals(v.car_model_id, 4)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:20,代码来源:vehicle.py
示例18: test_add_sts_to_vehicle
def test_add_sts_to_vehicle(self):
self.session.add(self.u1)
self.session.add(self.v1)
self.assertIsNone(self.v1.car_sts)
self.assertIsNone(self.v1.car_number)
data = server.addSTS(self.u1.id, self.v1.id, "321232", "А123СТ")
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'321232')
self.assertEquals(v.car_number, u'А123СТ')
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:21,代码来源:vehicle.py
示例19: test_unreg_normal
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,代码行数:22,代码来源:device.py
示例20: test_add_new_geo
def test_add_new_geo(self):
self.session.add(self.u1)
self.session.add(self.d1)
data = server.addDGeo(user_id=self.u1.ID, device_id=self.d1.device_ID,
name="New test geo", shape=0, center="54.123,55.123", radius=100)
self.assertJsonRpc(data)
self.assertIs(data['result'], True)
""" Separate session, cause cross-session's transaction collision """
s = Session()
d = s.query(TrDevice).get(self.d1.device_ID)
self.assertEquals(len(d.geos), 1)
self.assertEquals(d.geos[0].name, u'New test geo')
self.assertEquals(d.geos[0].shape, 0)
self.assertEquals(d.geos[0].center, u'54.123,55.123')
self.assertEquals(d.geos[0].radius, 100)
self.assertEquals(d.geos[0].state, True)
s.close()
开发者ID:toxxin,项目名称:TrackerRestApi,代码行数:23,代码来源:geo.py
注:本文中的tests.run.Session类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论