本文整理汇总了Python中camelot.core.orm.Session.delete方法的典型用法代码示例。如果您正苦于以下问题:Python Session.delete方法的具体用法?Python Session.delete怎么用?Python Session.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类camelot.core.orm.Session
的用法示例。
在下文中一共展示了Session.delete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_fixture
# 需要导入模块: from camelot.core.orm import Session [as 别名]
# 或者: from camelot.core.orm.Session import delete [as 别名]
def test_fixture( self ):
from camelot.model.party import Person
from camelot.model.fixture import Fixture
session = Session()
self.assertEqual( Fixture.find_fixture_key( Person, -1 ), None )
p1 = Person()
self.assertEqual( Fixture.find_fixture_key_and_class( p1 ),
(None, None) )
session.expunge( p1 )
# insert a new Fixture
p2 = Fixture.insert_or_update_fixture( Person, 'test',
{'first_name':'Peter',
'last_name':'Principle'},
fixture_class = 'test' )
# see if we can find it back
self.assertEqual( Fixture.find_fixture_key( Person, p2.id ), 'test' )
self.assertEqual( Fixture.find_fixture_key_and_class( p2 ),
('test', 'test') )
self.assertEqual( Fixture.find_fixture_keys_and_classes( Person )[p2.id],
('test', 'test') )
# delete the person, and insert it back in the same fixture
session.delete( p2 )
session.flush()
p3 = Fixture.insert_or_update_fixture( Person, 'test',
{'first_name':'Peter',
'last_name':'Principle'},
fixture_class = 'test' )
self.assertNotEqual( p2, p3 )
# remove all fixtures
Fixture.remove_all_fixtures( Person )