@@ -447,6 +447,56 @@ def test_mod_watch(self):
447
447
448
448
self .assertDictEqual (mount .mod_watch (name , sfun = 'unmount' ), ret )
449
449
450
+ def test_mounted_multiple_mounts (self ):
451
+ '''
452
+ Test to verify that a device is mounted.
453
+ '''
454
+ name = '/mnt/nfs1'
455
+ device = 'localhost:/mnt/nfsshare'
456
+ fstype = 'nfs4'
457
+
458
+ name2 = '/mnt/nfs2'
459
+ device2 = 'localhost:/mnt/nfsshare'
460
+ fstype2 = 'nfs4'
461
+
462
+ ret = {'name' : name ,
463
+ 'result' : False ,
464
+ 'comment' : '' ,
465
+ 'changes' : {}}
466
+
467
+ mock = MagicMock (side_effect = ['new' , 'present' , 'new' , 'change' ,
468
+ 'bad config' , 'salt' , 'present' ])
469
+ mock_t = MagicMock (return_value = True )
470
+ mock_f = MagicMock (return_value = False )
471
+ mock_ret = MagicMock (return_value = {'retcode' : 1 })
472
+ mock_mnt = MagicMock (return_value = {name : {'device' : device , 'opts' : [],
473
+ 'superopts' : []}})
474
+ mock_read_cache = MagicMock (return_value = {})
475
+ mock_write_cache = MagicMock (return_value = True )
476
+ mock_user = MagicMock (return_value = {'uid' : 510 })
477
+ mock_group = MagicMock (return_value = {'gid' : 100 })
478
+ mock_str = MagicMock (return_value = 'salt' )
479
+ mock_fstab_config = ['localhost:/mnt/nfsshare /mnt/nfs1 nfs defaults 0 0' ]
480
+
481
+ # Test no change for uid provided as a name #25293
482
+ with patch .dict (mount .__grains__ , {'os' : 'CentOS' }):
483
+ with patch .dict (mount .__opts__ , {'test' : True }):
484
+ with patch .dict (mount .__salt__ , {'mount.active' : mock_mnt ,
485
+ 'mount.mount' : mock_str ,
486
+ 'mount.umount' : mock_f ,
487
+ 'mount.read_mount_cache' : mock_read_cache ,
488
+ 'mount.write_mount_cache' : mock_write_cache ,
489
+ 'user.info' : mock_user ,
490
+ 'group.info' : mock_group }):
491
+ with patch .object (os .path , 'exists' , mock_t ):
492
+ comt = '/mnt/nfs2 would be mounted'
493
+ ret .update ({'name' : name2 , 'result' : None })
494
+ ret .update ({'comment' : comt , 'changes' : {}})
495
+ self .assertDictEqual (mount .mounted (name2 , device2 ,
496
+ fstype2 ,
497
+ opts = []),
498
+ ret )
499
+
450
500
def test__convert_to_fast_none (self ):
451
501
'''
452
502
Test the device name conversor
0 commit comments