def test_git_sub_dir(repo): git = sources._create_source("test_git", { "type": "git", "key": "changeme", "repo": repo, "sub_dir": "toto" }) assert git._do_sparse() git.refresh() subprocess.check_call(["ls", "/config/test_git"]) assert os.path.isfile("/config/test_git/test") assert not os.path.isfile("/config/test_git/.git") with open("/config/test_git/test") as file: assert file.read() == "Hello world" repo_file_path = os.path.join(repo, "toto", "test") with open(repo_file_path, "w") as file: file.write("Good bye") subprocess.check_call(["git", "add", repo_file_path], cwd=repo, stderr=subprocess.STDOUT) subprocess.check_call(["git", "commit", "-a", "-m", "Initial commit"], cwd=repo, stderr=subprocess.STDOUT) git.refresh() try: assert os.path.isfile("/config/test_git/test") with open("/config/test_git/test") as file: assert file.read() == "Good bye" finally: git.delete()
def test_rsync(): source = sources._create_source( "test_rsync", { "type": "rsync", "source": "/app/tests/sources", "excludes": ["test_git.py"] }) source.refresh() assert os.path.isfile("/config/test_rsync/test_rsync.py") assert not os.path.isfile("/config/test_rsync/test_git.py")
def test_rsync(): source = sources._create_source( "test_rclone", { "type": "rclone", "config": """\ type = http url = http://ftp.debian.org/debian/pool/main/p/p4est// """, "source": "test:", "excludes": ["*.deb", "*.tar.xz"], }, ) source.refresh() assert os.path.isfile("/config/test_rclone/p4est_1.1-5.dsc") assert not os.path.isfile( "/config/test_rclone/libp4est-sc-1.1_1.1-4_amd64.deb") assert not os.path.isfile("/config/test_rclone/p4est_1.1.orig.tar.xz")
def test_git_with_key(): ssh_key = os.environ["PRIVATE_SSH_KEY"].split(" ") ssh_key = ["-----BEGIN RSA PRIVATE KEY-----"] ssh_key += os.environ["PRIVATE_SSH_KEY"].split(" ")[4:-4] ssh_key += ["-----END RSA PRIVATE KEY-----"] ssh_key = [k for k in ssh_key if k != ""] git = sources._create_source( "test_key", { "type": "git", "repo": "[email protected]:camptocamp/private-geo-charts.git", "key": "changeme", "ssh_key": "\n".join(ssh_key), }, ) git.refresh() assert os.path.isfile("/config/test_key/README.md")