def test_rsync_excludes_str(self): ''' Test for rsync files from src to dst with one exclude ''' mock = { 'config.option': MagicMock(return_value=False), 'cmd.run_all': MagicMock() } with patch.dict(rsync.__salt__, mock): rsync.rsync('src', 'dst', exclude='test/one') mock['cmd.run_all'].assert_called_once_with( ['rsync', '-avz', '--exclude', 'test/one', 'src', 'dst'], python_shell=False, )
def test_rsync_excludes_str(self): """ Test for rsync files from src to dst with one exclude """ mock = { "config.option": MagicMock(return_value=False), "cmd.run_all": MagicMock(), } with patch.dict(rsync.__salt__, mock): rsync.rsync("src", "dst", exclude="test/one") mock["cmd.run_all"].assert_called_once_with( ["rsync", "-avz", "--exclude", "test/one", "src", "dst"], python_shell=False, )
def test_rsync(self): ''' Test for rsync files from src to dst ''' with patch.dict(rsync.__salt__, {'config.option': MagicMock(return_value=False)}): self.assertRaises(SaltInvocationError, rsync.rsync, '', '') with patch.dict(rsync.__salt__, {'config.option': MagicMock(return_value='A'), 'cmd.run': MagicMock(side_effect=[IOError('f'), 'A'])}): with patch.object(rsync, '_check', return_value=['A']): self.assertRaises(CommandExecutionError, rsync.rsync, 'a', 'b') self.assertEqual(rsync.rsync('src', 'dst'), 'A')
def test_rsync(self): ''' Test for rsync files from src to dst ''' with patch.dict(rsync.__salt__, {'config.option': MagicMock(return_value=False)}): self.assertRaises(SaltInvocationError, rsync.rsync, '', '') with patch.dict(rsync.__salt__, {'config.option': MagicMock(return_value='A'), 'cmd.run_all': MagicMock(side_effect=[OSError(1, 'f'), 'A'])}): with patch.object(rsync, '_check', return_value=['A']): self.assertRaises(CommandExecutionError, rsync.rsync, 'a', 'b') self.assertEqual(rsync.rsync('src', 'dst'), 'A')
def test_rsync(self): """ Test for rsync files from src to dst """ with patch.dict(rsync.__salt__, {"config.option": MagicMock(return_value=False)}): self.assertRaises(SaltInvocationError, rsync.rsync, "", "") with patch.dict( rsync.__salt__, { "config.option": MagicMock(return_value="A"), "cmd.run_all": MagicMock(side_effect=[OSError(1, "f"), "A"]), }, ): with patch.object(rsync, "_check", return_value=["A"]): self.assertRaises(CommandExecutionError, rsync.rsync, "a", "b") self.assertEqual(rsync.rsync("src", "dst"), "A")