Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #43 from uber/dn-builder-delete-fix
Browse files Browse the repository at this point in the history
Fixed FixtureManager.delete_fixture to use the injected builder
  • Loading branch information
charlax committed Mar 12, 2015
2 parents d0e25ff + e048f56 commit 288d832
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Changelog for Charlatan
=======================

(unreleased)
------------

- Fixed bug where uninstalling a sqlalchemy fixture would not commit the delete
to the session.

0.4.1 (2015-02-26)
------------------

Expand Down
2 changes: 1 addition & 1 deletion charlatan/fixtures_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def delete_fixture(self, fixture_key, builder=None):
if instance:
self.cache.pop(fixture_key, None)
self.installed_keys.remove(fixture_key)
self.delete_builder(self, instance)
builder(self, instance)

self.get_hook("after_delete")(fixture_key)

Expand Down
11 changes: 11 additions & 0 deletions charlatan/tests/test_sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,14 @@ def test_explicit_foreign_key(self):
"""Verify that we can get a db-computed foreign key explicitely."""
model = self.manager.install_fixture('model_with_explicit_fk')
assert model.color_id is not None

def test_uninstall_deletes_fixtures(self):
"""Verify uninstalling a fixture drops it from the database"""
self.manager.install_fixture("color")

# sanity check
self.assertEqual(self.session.query(Color).count(), 1)

self.manager.uninstall_fixture("color")

self.assertEqual(self.session.query(Color).count(), 0)

0 comments on commit 288d832

Please sign in to comment.