Repository: iterative/dvc

Issue:
cloud versioning: add tests
Need to add testing for cloud versioning (this could be a meta-ticket for tests in other packages for each cloud filesystem).

Thanks to @dtrifiro for pointing out that we can use versioned mock remotes for S3 and GCS starting from https://github.com/iterative/pytest-servers/releases/tag/0.2.0.


Discussion:
I would call this `p0` 😄 
I thought maybe I was being a little overly aggressive putting p0 on cloud versioning issues since it's still in development, but agreed that it needs to be one of the essential stories of the epic for release.
> I thought maybe I was being a little overly aggressive putting p0 on cloud versioning issues since it's still in development, but agreed that it needs to be one of the essential stories of the epic for release.

It was just a joke to remark importance 😅 
I have to add tests for output-specific remotes after we have the tests infrastructure. See https://github.com/iterative/dvc/pull/8862.

Resolving patch:
diff --git a/dvc/repo/imp_url.py b/dvc/repo/imp_url.py
--- a/dvc/repo/imp_url.py
+++ b/dvc/repo/imp_url.py
@@ -90,11 +90,10 @@ def imp_url(  # noqa: C901
         stage.save_deps()
         stage.md5 = stage.compute_md5()
     else:
+        if stage.deps[0].fs.version_aware:
+            stage.outs[0].can_push = False
         stage.run(jobs=jobs, no_download=no_download)
 
-    if not no_exec and stage.deps[0].fs.version_aware:
-        stage.outs[0].can_push = False
-
     stage.frozen = frozen
     stage.dump()
     return stage


Test patch:
diff --git a/dvc/testing/remote_tests.py b/dvc/testing/remote_tests.py
--- a/dvc/testing/remote_tests.py
+++ b/dvc/testing/remote_tests.py
@@ -243,3 +243,26 @@ def test_deletion(
         scm.checkout(v1)
         dvc.pull()
         assert (tmp_dir / "data_dir" / "data").read_text() == "data"
+
+    def test_update(
+        self, tmp_dir, dvc, remote_worktree  # pylint: disable=W0613
+    ):
+        tmp_dir.dvc_gen("foo", "foo")
+        tmp_dir.dvc_gen(
+            {
+                "data_dir": {
+                    "data_sub_dir": {"data_sub": "data_sub"},
+                    "data": "data",
+                    "empty": "",
+                }
+            }
+        )
+        dvc.push()
+        (remote_worktree / "foo").write_text("bar")
+        (remote_worktree / "data_dir" / "data").write_text("modified")
+        (remote_worktree / "data_dir" / "new_data").write_text("new data")
+
+        dvc.update([str(tmp_dir / "foo.dvc"), str(tmp_dir / "data_dir.dvc")])
+        assert (tmp_dir / "foo").read_text() == "bar"
+        assert (tmp_dir / "data_dir" / "data").read_text() == "modified"
+        assert (tmp_dir / "data_dir" / "new_data").read_text() == "new data"
diff --git a/dvc/testing/workspace_tests.py b/dvc/testing/workspace_tests.py
--- a/dvc/testing/workspace_tests.py
+++ b/dvc/testing/workspace_tests.py
@@ -2,6 +2,7 @@
 from typing import Dict, Union
 
 import pytest
+from funcy import first
 
 from dvc.exceptions import URLMissingError
 from dvc.repo import Repo
@@ -88,6 +89,42 @@ def test_import_empty_dir(
         assert tuple(empty_dir.iterdir()) == ()
 
 
+class TestImportURLVersionAware:
+    def test_import_file(self, tmp_dir, dvc, remote_version_aware):
+        remote_version_aware.gen("file", "file")
+        dvc.imp_url("remote://upstream/file", version_aware=True)
+        stage = first(dvc.index.stages)
+        assert not stage.outs[0].can_push
+        assert (tmp_dir / "file").read_text() == "file"
+        assert dvc.status() == {}
+
+        (remote_version_aware / "file").write_text("modified")
+        assert dvc.status().get("file.dvc") == [
+            {"changed deps": {"remote://upstream/file": "update available"}},
+        ]
+        dvc.update(str(tmp_dir / "file.dvc"))
+        assert (tmp_dir / "file").read_text() == "modified"
+        assert dvc.status() == {}
+
+    def test_import_dir(self, tmp_dir, dvc, remote_version_aware):
+        remote_version_aware.gen({"data_dir": {"file": "file"}})
+        dvc.imp_url("remote://upstream/data_dir", version_aware=True)
+        stage = first(dvc.index.stages)
+        assert not stage.outs[0].can_push
+        assert (tmp_dir / "data_dir" / "file").read_text() == "file"
+        assert dvc.status() == {}
+
+        (remote_version_aware / "data_dir" / "file").write_text("modified")
+        (remote_version_aware / "data_dir" / "new_file").write_text("new")
+        assert dvc.status().get("data_dir.dvc") == [
+            {"changed deps": {"remote://upstream/data_dir": "modified"}},
+        ]
+        dvc.update(str(tmp_dir / "data_dir.dvc"))
+        assert (tmp_dir / "data_dir" / "file").read_text() == "modified"
+        assert (tmp_dir / "data_dir" / "new_file").read_text() == "new"
+        assert dvc.status() == {}
+
+
 class TestAdd:
     @pytest.fixture
     def hash_name(self):