<s> import datetime <EOL> import arrow <EOL> from flexmock import flexmock , flexmock_teardown <EOL> from orator import Model , SoftDeletes <EOL> from orator . orm import Builder <EOL> from orator . query import QueryBuilder <EOL> from ... import OratorTestCase <EOL> t = arrow . get ( ) . naive <EOL> class SoftDeletesTestCase ( OratorTestCase ) : <EOL> def tearDown ( self ) : <EOL> flexmock_teardown ( ) <EOL> def test_delete_sets_soft_deleted_column ( self ) : <EOL> model = flexmock ( SoftDeleteModelStub ( ) ) <EOL> model . set_exists ( True ) <EOL> builder = flexmock ( Builder ) <EOL> query_builder = flexmock ( QueryBuilder ( None , None , None ) ) <EOL> query = Builder ( query_builder ) <EOL> model . should_receive ( '<STR_LIT>' ) . and_return ( query ) <EOL> builder . should_receive ( '<STR_LIT>' ) . once ( ) . with_args ( '<STR_LIT:id>' , <NUM_LIT:1> ) . and_return ( query ) <EOL> builder . should_receive ( '<STR_LIT>' ) . once ( ) . with_args ( { '<STR_LIT>' : t } ) <EOL> model . delete ( ) <EOL> self . assertIsInstance ( model . deleted_at , datetime . datetime ) <EOL> def test_restore ( self ) : <EOL> model = flexmock ( SoftDeleteModelStub ( ) ) <EOL> model . set_exists ( True ) <EOL> model . should_receive ( '<STR_LIT>' ) . once ( ) <EOL> model . restore ( ) <EOL> self . assertIsNone ( model . deleted_at ) <EOL> class SoftDeleteModelStub ( SoftDeletes , Model ) : <EOL> def get_key ( self ) : <EOL> return <NUM_LIT:1> <EOL> def get_key_name ( self ) : <EOL> return '<STR_LIT:id>' <EOL> def from_datetime ( self , value ) : <EOL> return t </s>
