30
30
# Import from the future
31
31
from __future__ import absolute_import
32
32
33
+ import os
34
+
33
35
import pygit2
34
36
import unittest
35
37
36
38
from . import utils
37
39
38
40
SUBM_NAME = 'submodule'
39
41
SUBM_PATH = 'submodule'
40
- SUBM_URL = 'test .com/submodule.git '
41
- SUBM_HEAD_SHA = '784855caf26449a1914d2cf62d12b9374d76ae78 '
42
+ SUBM_URL = 'https://github .com/libgit2/pygit2 '
43
+ SUBM_HEAD_SHA = '819cbff552e46ac4b8d10925cc422a30aa04e78e '
42
44
43
45
class SubmoduleTest (utils .SubmoduleRepoTestCase ):
44
46
@@ -53,6 +55,8 @@ def test_listall_submodules(self):
53
55
54
56
def test_submodule_open (self ):
55
57
s = self .repo .lookup_submodule (SUBM_PATH )
58
+ self .repo .init_submodules ()
59
+ self .repo .update_submodules ()
56
60
r = s .open ()
57
61
self .assertIsNotNone (r )
58
62
self .assertEqual (str (r .head .target ), SUBM_HEAD_SHA )
@@ -69,5 +73,25 @@ def test_url(self):
69
73
s = self .repo .lookup_submodule (SUBM_PATH )
70
74
self .assertEqual (SUBM_URL , s .url )
71
75
76
+ def test_init_and_update (self ):
77
+ subrepo_file_path = os .path .join (self .repo_path , 'submodule' , 'setup.py' )
78
+ self .assertFalse (os .path .exists (subrepo_file_path ))
79
+ self .repo .init_submodules ()
80
+ self .repo .update_submodules ()
81
+ self .assertTrue (os .path .exists (subrepo_file_path ))
82
+
83
+ def test_specified_update (self ):
84
+ subrepo_file_path = os .path .join (self .repo_path , 'submodule' , 'setup.py' )
85
+ self .assertFalse (os .path .exists (subrepo_file_path ))
86
+ self .repo .init_submodules (submodules = ['submodule' ])
87
+ self .repo .update_submodules (submodules = ['submodule' ])
88
+ self .assertTrue (os .path .exists (subrepo_file_path ))
89
+
90
+ def test_oneshot_update (self ):
91
+ subrepo_file_path = os .path .join (self .repo_path , 'submodule' , 'setup.py' )
92
+ self .assertFalse (os .path .exists (subrepo_file_path ))
93
+ self .repo .update_submodules (init = True )
94
+ self .assertTrue (os .path .exists (subrepo_file_path ))
95
+
72
96
if __name__ == '__main__' :
73
97
unittest .main ()
0 commit comments