1
1
import fs .path
2
+ import fs .errors
2
3
from mock import patch
3
4
from nose .tools import eq_ , raises
4
5
from gitfs2 .repo import (
12
13
13
14
@patch ("appdirs.user_cache_dir" , return_value = "root" )
14
15
@patch ("gitfs2.repo.mkdir_p" )
15
- @patch ("os.path.exists " )
16
+ @patch ("fs.open_fs " )
16
17
@patch ("git.Repo" , autospec = True )
17
18
class TestGitFunctions :
18
19
def setUp (self ):
@@ -33,7 +34,7 @@ def setUp(self):
33
34
)
34
35
35
36
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 ]
37
38
git_clone (self .require )
38
39
fake_repo .clone_from .assert_called_with (
39
40
self .repo ,
@@ -47,7 +48,7 @@ def test_checkout_new(self, fake_repo, local_folder_exists, *_):
47
48
def test_checkout_new_with_submodules (
48
49
self , fake_repo , local_folder_exists , * _
49
50
):
50
- local_folder_exists .return_value = False
51
+ local_folder_exists .side_effect = [ fs . errors . CreateFailed ]
51
52
git_clone (self .require_with_submodule )
52
53
fake_repo .clone_from .assert_called_with (
53
54
self .repo ,
@@ -59,7 +60,6 @@ def test_checkout_new_with_submodules(
59
60
repo .git .submodule .assert_called_with ("update" , "--init" )
60
61
61
62
def test_git_update (self , fake_repo , local_folder_exists , * _ ):
62
- local_folder_exists .return_value = True
63
63
git_clone (self .require )
64
64
fake_repo .assert_called_with (self .expected_local_repo_path )
65
65
repo = fake_repo .return_value
@@ -68,7 +68,6 @@ def test_git_update(self, fake_repo, local_folder_exists, *_):
68
68
def test_git_update_with_submodules (
69
69
self , fake_repo , local_folder_exists , * _
70
70
):
71
- local_folder_exists .return_value = True
72
71
git_clone (self .require_with_submodule )
73
72
fake_repo .assert_called_with (self .expected_local_repo_path )
74
73
repo = fake_repo .return_value
@@ -77,7 +76,7 @@ def test_git_update_with_submodules(
77
76
def test_checkout_new_with_branch (
78
77
self , fake_repo , local_folder_exists , * _
79
78
):
80
- local_folder_exists .return_value = False
79
+ local_folder_exists .side_effect = [ fs . errors . CreateFailed ]
81
80
git_clone (self .require_with_branch )
82
81
fake_repo .clone_from .assert_called_with (
83
82
self .repo ,
@@ -92,15 +91,14 @@ def test_checkout_new_with_branch(
92
91
def test_update_existing_with_branch_parameter (
93
92
self , fake_repo , local_folder_exists , * _
94
93
):
95
- local_folder_exists .return_value = True
96
94
git_clone (self .require_with_branch )
97
95
repo = fake_repo .return_value
98
96
repo .git .checkout .assert_called_with ("ghpages" )
99
97
100
98
def test_checkout_new_with_reference (
101
99
self , fake_repo , local_folder_exists , * _
102
100
):
103
- local_folder_exists .return_value = False
101
+ local_folder_exists .side_effect = [ fs . errors . CreateFailed ]
104
102
git_clone (self .require_with_reference )
105
103
fake_repo .clone_from .assert_called_with (
106
104
self .repo ,
@@ -115,7 +113,6 @@ def test_checkout_new_with_reference(
115
113
def test_update_existing_with_reference_parameter (
116
114
self , fake_repo , local_folder_exists , * _
117
115
):
118
- local_folder_exists .return_value = True
119
116
git_clone (self .require_with_reference )
120
117
repo = fake_repo .return_value
121
118
repo .git .checkout .assert_called_with ("a-commit-reference" )
0 commit comments