def test_cp_copy_args(self): assert cp_copy_args(path_from="/foo", path_to="/bar", is_file=True) == ( "if [ -f /foo ]; then cp /foo /bar; fi" ) assert cp_copy_args(path_from="/foo", path_to="/bar", is_file=False) == ( "if [ -d /foo ]; then cp -r /foo/* /bar; fi" )
def test_cp_copy_args(self): assert cp_copy_args( path_from="/foo", path_to="/bar", is_file=True) == ("if [ -f /foo ]; then cp /foo /bar; fi;") assert cp_copy_args( path_from="/foo", path_to="/bar", is_file=False ) == ( 'if [ -d /foo ] && [ "$(ls -A /foo)" ]; then cp -R /foo/* /bar; fi;' )
def test_get_volume_args_host(self): host_path_store = V1ConnectionType( name="test_path", kind=V1ConnectionKind.HOST_PATH, schema=V1HostPathConnection( mount_path="/tmp", host_path="/tmp", read_only=True ), ) path_to = "/path/to/" path_from = os.path.join(host_path_store.store_path, "") assert get_volume_args(host_path_store, path_to, None) == "; ".join( [ get_or_create_args(path=path_to), cp_copy_args(path_from=path_from, path_to=path_to, is_file=False), ] ) host_path_store = V1ConnectionType( name="test_claim", kind=V1ConnectionKind.HOST_PATH, schema=V1HostPathConnection( mount_path="/tmp", host_path="/tmp", read_only=True ), ) base_path = "/path/to/" path_to1 = "/path/to/path1" path_to2 = "/path/to/path2" path_from1 = os.path.join(host_path_store.store_path, "path1") path_from2 = os.path.join(host_path_store.store_path, "path2") assert get_volume_args( host_path_store, "/path/to", artifacts=V1ArtifactsType(dirs=["path1", "path2"]), ) == "; ".join( [ get_or_create_args(path=base_path), cp_copy_args(path_from=path_from1, path_to=path_to1, is_file=False), get_or_create_args(path=base_path), cp_copy_args(path_from=path_from2, path_to=path_to2, is_file=False), ] )
def test_get_volume_args_claim(self): claim_store = V1ConnectionType( name="test_claim", kind=V1ConnectionKind.VOLUME_CLAIM, schema=V1ClaimConnection(mount_path="/tmp", volume_claim="test", read_only=True), ) path_to = "/path/to/" path_from = os.path.join(claim_store.store_path, "") assert get_volume_args(claim_store, path_to, None) == "; ".join([ get_or_create_args(path=path_to), cp_copy_args(path_from=path_from, path_to=path_to, is_file=False), ]) claim_store = V1ConnectionType( name="test_claim", kind=V1ConnectionKind.VOLUME_CLAIM, schema=V1ClaimConnection(mount_path="/tmp", volume_claim="test", read_only=True), ) base_path = "/path/to/" path_to1 = "/path/to/path1" path_to2 = "/path/to/path2" path_from1 = os.path.join(claim_store.store_path, "path1") path_from2 = os.path.join(claim_store.store_path, "path2") assert get_volume_args( claim_store, "/path/to", artifacts=V1ArtifactsType(files=["path1", "path2"])) == "; ".join([ get_or_create_args(path=base_path), cp_copy_args(path_from=path_from1, path_to=path_to1, is_file=True), get_or_create_args(path=base_path), cp_copy_args(path_from=path_from2, path_to=path_to2, is_file=True), ])