コード例 #1
0
def test_scm_context(dvc, mocker):
    scm = dvc.scm
    m = mocker.patch.object(scm,
                            "track_file_changes",
                            wraps=scm.track_file_changes)

    ret_val = 0
    wrapped = scm_context(mocker.Mock(return_value=ret_val))

    assert wrapped(dvc) == ret_val
    m.assert_called_once_with(config=dvc.config)
コード例 #2
0
    def test_should_successfully_perform_method(self):
        method = mock.Mock()
        wrapped = scm_context(method)

        wrapped(self.repo_mock)

        self.assertEqual(1, method.call_count)
        self.assertEqual(1, self.scm_mock.reset_ignores.call_count)
        self.assertEqual(1, self.scm_mock.remind_to_track.call_count)

        self.assertEqual(0, self.scm_mock.cleanup_ignores.call_count)
コード例 #3
0
ファイル: test_scm.py プロジェクト: zivzone/dvc
    def test_should_throw_and_cleanup(self):
        method = mock.Mock(side_effect=Exception("some problem"))
        wrapped = scm_context(method)

        with self.assertRaises(Exception):
            wrapped(self.repo_mock)

        self.assertEqual(1, method.call_count)
        self.assertEqual(1, self.scm_mock.cleanup_ignores.call_count)

        self.assertEqual(0, self.scm_mock.reset_ignores.call_count)
        self.assertEqual(0, self.scm_mock.remind_to_track.call_count)
コード例 #4
0
ファイル: test_scm.py プロジェクト: zivzone/dvc
    def test_should_check_autostage(self):
        method = mock.Mock()
        wrapped = scm_context(method)

        config_autostage_attrs = {"config": {"core": {"autostage": True}}}
        self.repo_mock.configure_mock(**config_autostage_attrs)
        wrapped(self.repo_mock)

        self.assertEqual(1, method.call_count)
        self.assertEqual(1, self.scm_mock.reset_ignores.call_count)
        self.assertEqual(1, self.scm_mock.track_changed_files.call_count)

        self.assertEqual(0, self.scm_mock.cleanup_ignores.call_count)