8
8
import git
9
9
10
10
11
- @patch ('ide.git.get_github' )
12
- @patch ('ide.git.git_verify_tokens' )
13
- class CreateRepoTest (TestCase ):
14
- def test_expected_call (self , mock_verify_tokens , mock_get_github ):
15
- mock_user = MagicMock ()
16
- mock_github = Mock ()
17
- mock_github .get_user = Mock (return_value = mock_user )
18
- mock_get_github .return_value = mock_github
19
-
20
- self .assertTrue (git .create_repo ("user" , "repo" , "description" ))
21
-
22
- mock_verify_tokens .called_once_with ("user" )
23
- mock_get_github .called_once_with ("user" )
24
- mock_user .create_repo .called_once_with ("repo" , description = "description" , auto_init = True )
25
-
26
-
27
11
@patch ('ide.git.git_verify_tokens' )
28
12
class GitAuthCheckTest (TestCase ):
29
13
def setUp (self ):
@@ -62,7 +46,6 @@ def test_successful_auth_check(self, mock_verify_tokens):
62
46
self .assertItemsEqual (self .mock_user .github .delete .call_args_list , [])
63
47
64
48
65
-
66
49
@patch ('ide.git.urllib2.urlopen' )
67
50
@patch ('ide.git.json.loads' )
68
51
@patch ('ide.git.urllib2.Request' )
@@ -131,6 +114,21 @@ def test_github_token_verified(self, request_mock, loads_mock, urlopen_mock):
131
114
urlopen_mock .called_once_with (request_mock )
132
115
133
116
117
+ class GetGithubTest (TestCase ):
118
+ def setUp (self ):
119
+ self .mock_user = Mock ()
120
+ self .mock_user .github = Mock ()
121
+ self .mock_user .github .token = "12345"
122
+
123
+ @patch ('ide.git.Github' )
124
+ def test_get_github_basic (self , mock_github ):
125
+ test_result = git .get_github (self .mock_user )
126
+ mock_github .assert_called_once_with (
127
+ "12345" ,
128
+ client_id = settings .GITHUB_CLIENT_ID ,
129
+ client_secret = settings .GITHUB_CLIENT_SECRET )
130
+
131
+
134
132
@patch ('ide.git.get_github' )
135
133
class CheckRepoAccessTest (TestCase ):
136
134
def setUp (self ):
@@ -180,19 +178,6 @@ def test_get_repo_error(self, mock_get_github):
180
178
self .mock_github .get_repo .called_once_with (self .repo_name )
181
179
self .assertItemsEqual (self .mock_repo .call_args_list , [])
182
180
183
- class GetGithubTest (TestCase ):
184
- def setUp (self ):
185
- self .mock_user = Mock ()
186
- self .mock_user .github = Mock ()
187
- self .mock_user .github .token = "12345"
188
-
189
- @patch ('ide.git.Github' )
190
- def test_get_github_basic (self , mock_github ):
191
- test_result = git .get_github (self .mock_user )
192
- mock_github .assert_called_once_with (
193
- "12345" ,
194
- client_id = settings .GITHUB_CLIENT_ID ,
195
- client_secret = settings .GITHUB_CLIENT_SECRET )
196
181
197
182
class UrlToReposTest (TestCase ):
198
183
def test_basic_url_to_repo (self ):
@@ -217,3 +202,19 @@ def test_bad_url_to_repo(self):
217
202
Tests that a entirely different url returns None.
218
203
"""
219
204
self .assertEqual (None , git .url_to_repo ("http://www.cuteoverload.com" ))
205
+
206
+
207
+ @patch ('ide.git.get_github' )
208
+ @patch ('ide.git.git_verify_tokens' )
209
+ class CreateRepoTest (TestCase ):
210
+ def test_expected_call (self , mock_verify_tokens , mock_get_github ):
211
+ mock_user = MagicMock ()
212
+ mock_github = Mock ()
213
+ mock_github .get_user = Mock (return_value = mock_user )
214
+ mock_get_github .return_value = mock_github
215
+
216
+ self .assertTrue (git .create_repo ("user" , "repo" , "description" ))
217
+
218
+ mock_verify_tokens .called_once_with ("user" )
219
+ mock_get_github .called_once_with ("user" )
220
+ mock_user .create_repo .called_once_with ("repo" , description = "description" , auto_init = True )
0 commit comments