def test_read_config_parser_with_hook_pre_command(self, mock_wrapper): hook = {'hook_pre_command': 'ls -l'} data = [('absoluthe_share', {'hostname': 'server_windows.example', 'share': 'condivisione', 'mountpoint': '/mnt/mountpoint'})] data[0][1].update(hook) with patch('pygmount.core.samba.ConfigParser', get_fake_configparser(data)): mss = MountSmbShares() mss.set_shares() mock_wrapper.assert_called_once_with(data[0][1]['hostname'], data[0][1]['share'], data[0][1]['mountpoint']) self.assertEqual(len(mss.shares), 1) self.assertEqual(mss.shares[0][2], list(hook.values())[0])
def test_read_config_parser_simple(self, mock_wrapper): data = [('absoluthe_share', {'hostname': 'server_windows.example', 'share': 'condivisione', 'mountpoint': '/mnt/mountpoint'})] with patch('pygmount.core.samba.ConfigParser', get_fake_configparser(data)): mss = MountSmbShares() mss.set_shares() mock_wrapper.assert_called_once_with(data[0][1]['hostname'], data[0][1]['share'], data[0][1]['mountpoint']) self.assertEqual(len(mss.shares), 1) self.assertEqual(mss.shares[0][0], data[0][0]) self.assertIsNone(mss.shares[0][2]) self.assertIsNone(mss.shares[0][3])
def test_read_config_parser_with_options(self, mock_wrapper): options = {'option_1': 'option_1', 'option_2': 'option_2'} data = [ ('absoluthe_share', {'hostname': 'server_windows.example', 'share': 'condivisione', 'mountpoint': '/mnt/mountpoint'})] data[0][1].update(options) with patch('pygmount.core.samba.ConfigParser', get_fake_configparser(data)): mss = MountSmbShares() mss.set_shares() mock_wrapper.assert_called_once_with( data[0][1]['hostname'], data[0][1]['share'], data[0][1]['mountpoint'], **options) self.assertEqual(len(mss.shares), 1) self.assertEqual(mss.shares[0][0], data[0][0])
def test_read_config_parser_with_only_username_and_password( self, mock_wrapper): username = '******' password = '******' hostname = 'server_windows.example' data = [('absoluthe_share', {'hostname': username + ':' + password + '@' + hostname, 'share': 'condivisione', 'mountpoint': '/mnt/mountpoint'})] with patch('pygmount.core.samba.ConfigParser', get_fake_configparser(data)): mss = MountSmbShares() mss.set_shares() mock_wrapper.assert_called_once_with(hostname, data[0][1]['share'], data[0][1][ 'mountpoint'], username=username, password=password) self.assertEqual(len(mss.shares), 1) self.assertEqual(mss.shares[0][0], data[0][0])