#NEWLINE# def test_run_once_node_is_mounted( self ) : #NEWLINE# #INDENT# db_replicator . ring = FakeRingWithSingleNode ( ) #NEWLINE# conf = { #NEWLINE# #INDENT# 'mount_check' : 'true' , #NEWLINE# 'bind_port' : 6200 , #NEWLINE# #UNINDENT# } #NEWLINE# replicator = TestReplicator ( conf , logger = unit . FakeLogger ( ) ) #NEWLINE# self . assertEqual ( replicator . mount_check , True ) #NEWLINE# self . assertEqual ( replicator . port , 6200 ) #NEWLINE# def mock_unlink_older_than( path , mtime ) : #NEWLINE# #INDENT# self . assertEqual ( path , os . path . join ( replicator . root , replicator . ring . devs [ 0 ] [ 'device' ] , 'tmp' ) ) #NEWLINE# self . assertTrue ( ( ( time . time ( ) - replicator . reclaim_age ) >= mtime ) ) #NEWLINE# #UNINDENT# def mock_spawn_n( fn , part , object_file , node_id ) : #NEWLINE# #INDENT# self . assertEqual ( '123' , part ) #NEWLINE# self . assertEqual ( '/srv/node/sda/c.db' , object_file ) #NEWLINE# self . assertEqual ( 1 , node_id ) #NEWLINE# #UNINDENT# self . _patch ( patch . object , db_replicator , 'whataremyips' , ( lambda * a , **kw : [ '1.1.1.1' ] ) ) #NEWLINE# self . _patch ( patch . object , db_replicator , 'ismount' , ( lambda * args : True ) ) #NEWLINE# self . _patch ( patch . object , db_replicator , 'unlink_older_than' , mock_unlink_older_than ) #NEWLINE# self . _patch ( patch . object , db_replicator , 'roundrobin_datadirs' , ( lambda * args : [ ( '123' , '/srv/node/sda/c.db' , 1 ) ] ) ) #NEWLINE# self . _patch ( patch . object , replicator . cpool , 'spawn_n' , mock_spawn_n ) #NEWLINE# with patch ( 'swift.common.db_replicator.os' , new = mock . MagicMock ( wraps = os ) ) as mock_os : #NEWLINE# #INDENT# mock_os . path . isdir . return_value = True #NEWLINE# replicator . run_once ( ) #NEWLINE# mock_os . path . isdir . assert_called_with ( os . path . join ( replicator . root , replicator . ring . devs [ 0 ] [ 'device' ] , replicator . datadir ) )