Skip to content

Commit

Permalink
Move test to output and use mocker
Browse files Browse the repository at this point in the history
  • Loading branch information
nsorros committed Apr 7, 2022
1 parent 69138aa commit 8a37f70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
19 changes: 0 additions & 19 deletions tests/func/test_data_cloud.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import os
import shutil
from unittest.mock import patch

import pytest
from flaky.flaky_decorator import flaky
Expand All @@ -10,7 +9,6 @@
from dvc.cli import main
from dvc.data.db.local import LocalObjectDB
from dvc.external_repo import clean_repos
from dvc.fs.base import RemoteMissingDepsError
from dvc.objects.db import ObjectDB
from dvc.stage.exceptions import StageNotFound
from dvc.testing.test_remote import ( # noqa, pylint: disable=unused-import
Expand Down Expand Up @@ -572,20 +570,3 @@ def test_target_remote(tmp_dir, dvc, make_remote):
"6b18131dc289fd37006705affe961ef8.dir",
"b8a9f715dbb64fd5c56e7783c6820a61",
}


def test_remote_missing_data_dir(tmp_dir, scm, dvc, make_remote):
tmp_dir.dvc_gen({"dir": {"subfile": "file2 content"}}, commit="add dir")
with dvc.config.edit() as conf:
conf["remote"]["s3"] = {"url": "s3://bucket/name"}
conf["core"] = {"remote": "s3"}

remove("dir")
remove(dvc.odb.local.cache_dir)

with patch(
"dvc.data_cloud.DataCloud.get_remote_odb",
side_effect=RemoteMissingDepsError("remote missing"),
):
with pytest.raises(RemoteMissingDepsError):
dvc.pull()
19 changes: 19 additions & 0 deletions tests/unit/output/test_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
from funcy import first
from voluptuous import MultipleInvalid, Schema

from dvc.fs.base import RemoteMissingDepsError
from dvc.ignore import _no_match
from dvc.output import CHECKSUM_SCHEMA, Output
from dvc.stage import Stage
from dvc.utils.fs import remove


def test_save_missing(dvc, mocker):
Expand Down Expand Up @@ -100,3 +102,20 @@ def test_get_used_objs(exists, expected_message, mocker, caplog):
with caplog.at_level(logging.WARNING, logger="dvc"):
assert {} == output.get_used_objs()
assert first(caplog.messages) == expected_message


def test_remote_missing_data_dir(tmp_dir, scm, dvc, mocker):
tmp_dir.dvc_gen({"dir": {"subfile": "file2 content"}}, commit="add dir")
with dvc.config.edit() as conf:
conf["remote"]["s3"] = {"url": "s3://bucket/name"}
conf["core"] = {"remote": "s3"}

remove("dir")
remove(dvc.odb.local.cache_dir)

with mocker.patch(
"dvc.data_cloud.DataCloud.get_remote_odb",
side_effect=RemoteMissingDepsError("remote missing"),
):
with pytest.raises(RemoteMissingDepsError):
dvc.pull()

0 comments on commit 8a37f70

Please sign in to comment.