Skip to content

Commit 283be24

Browse files
committed
💚 make tests pass
1 parent 3092189 commit 283be24

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

gitfs2/repo.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import fs
77
import fs.path
8+
import fs.errors
89
from gitfs2 import reporter, constants
910

1011

tests/test_git_repo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs
2-
from gitfs2.repo import git_clone, GitRequire
2+
from gitfs2.repo import GitRequire, git_clone
33

44

55
def test_clone_a_real_github():

tests/test_repo.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import fs.path
2+
import fs.errors
23
from mock import patch
34
from nose.tools import eq_, raises
45
from gitfs2.repo import (
@@ -12,7 +13,7 @@
1213

1314
@patch("appdirs.user_cache_dir", return_value="root")
1415
@patch("gitfs2.repo.mkdir_p")
15-
@patch("os.path.exists")
16+
@patch("fs.open_fs")
1617
@patch("git.Repo", autospec=True)
1718
class TestGitFunctions:
1819
def setUp(self):
@@ -33,7 +34,7 @@ def setUp(self):
3334
)
3435

3536
def test_checkout_new(self, fake_repo, local_folder_exists, *_):
36-
local_folder_exists.return_value = False
37+
local_folder_exists.side_effect = [fs.errors.CreateFailed]
3738
git_clone(self.require)
3839
fake_repo.clone_from.assert_called_with(
3940
self.repo,
@@ -47,7 +48,7 @@ def test_checkout_new(self, fake_repo, local_folder_exists, *_):
4748
def test_checkout_new_with_submodules(
4849
self, fake_repo, local_folder_exists, *_
4950
):
50-
local_folder_exists.return_value = False
51+
local_folder_exists.side_effect = [fs.errors.CreateFailed]
5152
git_clone(self.require_with_submodule)
5253
fake_repo.clone_from.assert_called_with(
5354
self.repo,
@@ -59,7 +60,6 @@ def test_checkout_new_with_submodules(
5960
repo.git.submodule.assert_called_with("update", "--init")
6061

6162
def test_git_update(self, fake_repo, local_folder_exists, *_):
62-
local_folder_exists.return_value = True
6363
git_clone(self.require)
6464
fake_repo.assert_called_with(self.expected_local_repo_path)
6565
repo = fake_repo.return_value
@@ -68,7 +68,6 @@ def test_git_update(self, fake_repo, local_folder_exists, *_):
6868
def test_git_update_with_submodules(
6969
self, fake_repo, local_folder_exists, *_
7070
):
71-
local_folder_exists.return_value = True
7271
git_clone(self.require_with_submodule)
7372
fake_repo.assert_called_with(self.expected_local_repo_path)
7473
repo = fake_repo.return_value
@@ -77,7 +76,7 @@ def test_git_update_with_submodules(
7776
def test_checkout_new_with_branch(
7877
self, fake_repo, local_folder_exists, *_
7978
):
80-
local_folder_exists.return_value = False
79+
local_folder_exists.side_effect = [fs.errors.CreateFailed]
8180
git_clone(self.require_with_branch)
8281
fake_repo.clone_from.assert_called_with(
8382
self.repo,
@@ -92,15 +91,14 @@ def test_checkout_new_with_branch(
9291
def test_update_existing_with_branch_parameter(
9392
self, fake_repo, local_folder_exists, *_
9493
):
95-
local_folder_exists.return_value = True
9694
git_clone(self.require_with_branch)
9795
repo = fake_repo.return_value
9896
repo.git.checkout.assert_called_with("ghpages")
9997

10098
def test_checkout_new_with_reference(
10199
self, fake_repo, local_folder_exists, *_
102100
):
103-
local_folder_exists.return_value = False
101+
local_folder_exists.side_effect = [fs.errors.CreateFailed]
104102
git_clone(self.require_with_reference)
105103
fake_repo.clone_from.assert_called_with(
106104
self.repo,
@@ -115,7 +113,6 @@ def test_checkout_new_with_reference(
115113
def test_update_existing_with_reference_parameter(
116114
self, fake_repo, local_folder_exists, *_
117115
):
118-
local_folder_exists.return_value = True
119116
git_clone(self.require_with_reference)
120117
repo = fake_repo.return_value
121118
repo.git.checkout.assert_called_with("a-commit-reference")

0 commit comments

Comments
 (0)