Skip to content

Commit

Permalink
Fix for pull
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyjb committed Oct 24, 2017
1 parent ded5fdd commit a43c074
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion mongoframes/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def nullify(cls, ref_cls, field, frames):
def pull(cls, ref_cls, field, frames):
"""Pull references from a list field (does not emit signals)"""
from mongoframes.queries import to_refs
ids = [to_refs(f[field]) for f in frames if f.get(field)]
ids = [to_refs(f) for f in frames]
ref_cls.get_collection().update_many(
{field: {'$in': ids}},
{'$pull': {field: {'$in': ids}}}
Expand Down
12 changes: 6 additions & 6 deletions tests/test_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@ def test_cascade(mongo_client, example_dataset_many):

# Listen for delete events against dragons and delete any associated lair at
# the same time.
def on_delete(sender, frames):
def on_deleted(sender, frames):
ComplexDragon.cascade(Lair, 'lair', frames)

ComplexDragon.listen('deleted', on_delete)
ComplexDragon.listen('deleted', on_deleted)

# Delete a dragon and check the associated lair is also deleted
burt = ComplexDragon.one(Q.name == 'Burt')
Expand Down Expand Up @@ -626,10 +626,10 @@ def test_pull(mongo_client, example_dataset_many):
# Listen for delete events against lairs and pull any deleted lair from the
# associated dragons. For the sake of the tests here we're storing multiple
# lairs against the lair attribute instead of the intended one.
def on_delete(sender, frames):
def on_deleted(sender, frames):
Lair.pull(ComplexDragon, 'lair', frames)

ComplexDragon.listen('deleted', on_delete)
Lair.listen('deleted', on_deleted)

# List Burt stay in a few lairs
castle = Lair.one(Q.name == 'Castle')
Expand All @@ -642,8 +642,8 @@ def on_delete(sender, frames):
# nullified.
lair = Lair.one(Q.name == 'Cave')
lair.delete()
burt.reload()
assert burt.lair == [castle]
burt.reload(projection=None)
assert burt.lair == [castle._id]

def test_listen(mongo_client):
"""Should add a callback for a signal against the class"""
Expand Down

0 comments on commit a43c074

Please sign in to comment.