Last active
December 14, 2015 10:19
-
-
Save apbarrero/5071643 to your computer and use it in GitHub Desktop.
Basic rsync_project up/downstream option tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| import os | |
| import tempfile | |
| import unittest | |
| import shutil | |
| from fabric.api import * | |
| from fabric.contrib.project import rsync_project | |
| class TestRsync(unittest.TestCase): | |
| def setUp(self): | |
| env.host_string = "antonio@localhost" | |
| self.srcdir = tempfile.mkdtemp() | |
| h, self.srcfile = tempfile.mkstemp(dir=self.srcdir, text=True) | |
| def test_rsync(self): | |
| self.dstdir = tempfile.mkdtemp() | |
| rsync_project(remote_dir=self.dstdir, local_dir=self.srcdir) | |
| dstfile = os.path.join(self.dstdir, os.path.basename(self.srcdir), os.path.basename(self.srcfile)) | |
| self.assertTrue(os.path.exists(dstfile)) | |
| def test_rsync_download(self): | |
| self.dstdir = tempfile.mkdtemp() | |
| rsync_project(remote_dir=self.srcdir, local_dir=self.dstdir, upload=False) | |
| dstfile = os.path.join(self.dstdir, os.path.basename(self.srcdir), os.path.basename(self.srcfile)) | |
| self.assertTrue(os.path.exists(dstfile)) | |
| def tearDown(self): | |
| shutil.rmtree(self.srcdir) | |
| shutil.rmtree(self.dstdir) | |
| if __name__ == '__main__': | |
| unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment