<s> import unittest <EOL> from pyramid import testing <EOL> class Test_delete_locks_for_resource ( unittest . TestCase ) : <EOL> def _callFUT ( self , event ) : <EOL> from . . subscribers import delete_locks_for_resource <EOL> return delete_locks_for_resource ( event ) <EOL> def test_event_moving ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . loading = False <EOL> event . moving = True <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_event_loading ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . loading = True <EOL> event . moving = None <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_objectmap_is_None ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . moving = None <EOL> event . loading = False <EOL> event . object = None <EOL> event . parent = testing . DummyResource ( ) <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_it ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . moving = None <EOL> event . loading = False <EOL> resource = testing . DummyResource ( ) <EOL> parent = testing . DummyResource ( ) <EOL> event . object = resource <EOL> event . removed_oids = [ <NUM_LIT:1> , <NUM_LIT:2> ] <EOL> event . parent = parent <EOL> lock = testing . DummyResource ( ) <EOL> lock . suicided = <NUM_LIT:0> <EOL> def commit_suicide ( ) : <EOL> lock . suicided += <NUM_LIT:1> <EOL> lock . commit_suicide = commit_suicide <EOL> parent . __objectmap__ = DummyObjectMap ( [ lock ] ) <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> self . assertEqual ( lock . suicided , <NUM_LIT:2> ) <EOL> class Test_delete_locks_for_user ( unittest . TestCase ) : <EOL> def _callFUT ( self , event ) : <EOL> from . . subscribers import delete_locks_for_user <EOL> return delete_locks_for_user ( event ) <EOL> def test_event_moving ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . loading = False <EOL> event . moving = True <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_event_loading ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . loading = True <EOL> event . moving = None <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_objectmap_is_None ( self ) : <EOL> event = testing . DummyResource ( ) <EOL> event . moving = None <EOL> event . loading = False <EOL> event . object = None <EOL> event . parent = testing . DummyResource ( ) <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> def test_it ( self ) : <EOL> from zope . interface import alsoProvides <EOL> from substanced . interfaces import IUser <EOL> event = testing . DummyResource ( ) <EOL> event . moving = None <EOL> event . loading = False <EOL> resource = testing . DummyResource ( ) <EOL> parent = testing . DummyResource ( ) <EOL> alsoProvides ( resource , IUser ) <EOL> event . object = resource <EOL> event . parent = parent <EOL> lock = testing . DummyResource ( ) <EOL> lock . suicided = <NUM_LIT:0> <EOL> def commit_suicide ( ) : <EOL> lock . suicided += <NUM_LIT:1> <EOL> lock . commit_suicide = commit_suicide <EOL> parent . __objectmap__ = DummyObjectMap ( [ lock ] ) <EOL> result = self . _callFUT ( event ) <EOL> self . assertEqual ( result , None ) <EOL> self . assertEqual ( lock . suicided , <NUM_LIT:1> ) <EOL> class DummyObjectMap ( object ) : <EOL> def __init__ ( self , result ) : <EOL> self . result = result <EOL> def targets ( self , resource , type ) : <EOL> return self . result </s>
