Skip to content
This repository has been archived by the owner on Apr 27, 2020. It is now read-only.

Commit

Permalink
Add a test when deleting an entity
Browse files Browse the repository at this point in the history
  • Loading branch information
hadrien committed Jun 5, 2014
1 parent 889abe6 commit 340c297
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pyramid_caching/tests/unittests/test_sqlalchemy_extension.py
Expand Up @@ -31,6 +31,10 @@ def setUp(self):
self.config = Configurator(settings={
'caching.enabled': True,
})

Session.add(User(name='hadrien', address='down the hill'))
Session.commit()

register_sqla_session_caching_hook(self.config, Session)
self.config.registry.registerAdapter(DummyIdentityInspector(),
required=[User],
Expand Down Expand Up @@ -67,6 +71,13 @@ def test_modify_entity(self):
Session.commit()
self.assertEqual(self.key_versioner.incr_keys, ['users', 'users:joe'])

def test_delete_entity(self):
user = Session.query(User).filter_by(name='hadrien').first()
Session.delete(user)
Session.commit()
self.assertEqual(self.key_versioner.incr_keys,
['users', 'users:hadrien'])


class User(object):
__tablename__ = 'users'
Expand Down

0 comments on commit 340c297

Please sign in to comment.