def test_export(self): """ Test to export a file or directory from an SVN repository """ mock = MagicMock(return_value=True) with patch.object(svn, "_fail", mock): self.assertTrue(svn.export("salt")) mock = MagicMock(side_effect=[True, False, False, False]) with patch.object(os.path, "exists", mock): mock = MagicMock(return_value=False) with patch.object(os.path, "isdir", mock): with patch.object(svn, "_fail", mock): self.assertFalse(svn.export("salt", "c://salt")) with patch.dict(svn.__opts__, {"test": True}): mock = MagicMock(return_value=["salt"]) with patch.object(svn, "_neutral_test", mock): self.assertListEqual(svn.export("salt", "c://salt"), ["salt"]) mock = MagicMock(side_effect=[False, True]) with patch.object(os.path, "exists", mock): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {"svn.list": mock}): mock = MagicMock(return_value=["Dude"]) with patch.object(svn, "_neutral_test", mock): self.assertListEqual(svn.export("salt", "c://salt"), ["Dude"]) with patch.dict(svn.__opts__, {"test": False}): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {"svn.export": mock}): self.assertDictEqual( svn.export("salt", "c://salt"), {"changes": "salt was Exported" " to c://salt", "comment": "", "name": "salt", "result": True}, )
def test_export(self): ''' Test to export a file or directory from an SVN repository ''' mock = MagicMock(return_value=True) with patch.object(svn, '_fail', mock): self.assertTrue(svn.export("salt")) mock = MagicMock(side_effect=[True, False, False, False]) with patch.object(os.path, 'exists', mock): mock = MagicMock(return_value=False) with patch.object(os.path, 'isdir', mock): with patch.object(svn, '_fail', mock): self.assertFalse(svn.export("salt", "c://salt")) with patch.dict(svn.__opts__, {'test': True}): mock = MagicMock(return_value=["salt"]) with patch.object(svn, '_neutral_test', mock): self.assertListEqual(svn.export("salt", "c://salt"), ['salt']) mock = MagicMock(side_effect=[False, True]) with patch.object(os.path, 'exists', mock): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {'svn.list': mock}): mock = MagicMock(return_value=["Dude"]) with patch.object(svn, '_neutral_test', mock): self.assertListEqual(svn.export("salt", "c://salt"), ['Dude']) with patch.dict(svn.__opts__, {'test': False}): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {'svn.export': mock}): self.assertDictEqual( svn.export("salt", "c://salt"), { 'changes': { 'new': 'salt', 'comment': 'salt was Exported to c://salt', }, 'comment': '', 'name': 'salt', 'result': True, } )
def test_export(self): """ Test to export a file or directory from an SVN repository """ mock = MagicMock(return_value=True) with patch.object(svn, "_fail", mock): self.assertTrue(svn.export("salt")) mock = MagicMock(side_effect=[True, False, False, False]) with patch.object(os.path, "exists", mock): mock = MagicMock(return_value=False) with patch.object(os.path, "isdir", mock): with patch.object(svn, "_fail", mock): self.assertFalse(svn.export("salt", "c://salt")) with patch.dict(svn.__opts__, {"test": True}): mock = MagicMock(return_value=["salt"]) with patch.object(svn, "_neutral_test", mock): self.assertListEqual(svn.export("salt", "c://salt"), ["salt"]) mock = MagicMock(side_effect=[False, True]) with patch.object(os.path, "exists", mock): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {"svn.list": mock}): mock = MagicMock(return_value=["Dude"]) with patch.object(svn, "_neutral_test", mock): self.assertListEqual( svn.export("salt", "c://salt"), ["Dude"]) with patch.dict(svn.__opts__, {"test": False}): mock = MagicMock(return_value=True) with patch.dict(svn.__salt__, {"svn.export": mock}): self.assertDictEqual( svn.export("salt", "c://salt"), { "changes": { "new": "salt", "comment": "salt was Exported to c://salt", }, "comment": True, "name": "salt", "result": True, }, )