2
2
from unittest import TestCase
3
3
from unittest .mock import Mock , patch
4
4
5
- import gist
5
+ import gist_80 as gist
6
6
from test .stubs import github_api , sublime
7
7
8
8
DEFAULT_GISTS_URL = 'https://api.github.com/gists?per_page=100'
@@ -22,21 +22,21 @@ def test_gist_copy_url(self,):
22
22
gist_copy_url .run (edit = None )
23
23
sublime .set_clipboard .assert_called_with (None )
24
24
25
- @patch ('gist .webbrowser' )
25
+ @patch ('gist_80 .webbrowser' )
26
26
def test_gist_open_browser (self , patch_gist_webbrowser ):
27
27
gist_open_browser = gist .GistOpenBrowser ()
28
28
gist_open_browser .run (edit = None )
29
29
patch_gist_webbrowser .open .assert_called_with (None )
30
30
31
- @patch ('gist .api_request' )
31
+ @patch ('gist_80 .api_request' )
32
32
def test_gist_list_command_base (self , mocked_api_request ):
33
33
gist .plugin_loaded ()
34
34
mocked_api_request .side_effect = [github_api .GIST_STARRED_LIST , github_api .GIST_LIST ]
35
35
gist .settings .set ('include_users' , ['some user' ])
36
36
gist .settings .set ('include_orgs' , ['some org' ])
37
37
gist_list_base = gist .GistListCommandBase ()
38
38
39
- with patch ('gist .GistListCommandBase.get_window' ) as mocked_get_window :
39
+ with patch ('gist_80 .GistListCommandBase.get_window' ) as mocked_get_window :
40
40
mocked_window = Mock ()
41
41
mocked_get_window .return_value = mocked_window
42
42
gist_list_base .run ()
@@ -71,7 +71,7 @@ def test_gist_list_command_base(self, mocked_api_request):
71
71
# pass flow
72
72
mocked_window .reset_mock ()
73
73
mocked_api_request .reset_mock ()
74
- with patch ('gist .GistListCommandBase.handle_gist' ) as mocked_handle_gist :
74
+ with patch ('gist_80 .GistListCommandBase.handle_gist' ) as mocked_handle_gist :
75
75
on_gist_num (- 1 )
76
76
77
77
self .assertEqual (mocked_api_request .call_count , 0 )
@@ -81,7 +81,7 @@ def test_gist_list_command_base(self, mocked_api_request):
81
81
# personal gists flow
82
82
mocked_window .reset_mock ()
83
83
mocked_api_request .reset_mock ()
84
- with patch ('gist .GistListCommandBase.handle_gist' ) as mocked_handle_gist :
84
+ with patch ('gist_80 .GistListCommandBase.handle_gist' ) as mocked_handle_gist :
85
85
on_gist_num (0 )
86
86
87
87
self .assertEqual (mocked_api_request .call_count , 0 )
@@ -116,32 +116,32 @@ def test_gist_list_command_base(self, mocked_api_request):
116
116
self .assertRaises (NotImplementedError , gist_list_base .handle_gist , None )
117
117
self .assertRaises (NotImplementedError , gist_list_base .get_window )
118
118
119
- @patch ('gist .open_gist' )
119
+ @patch ('gist_80 .open_gist' )
120
120
def test_gist_list_command (self , mocked_open_gist ):
121
121
mocked_window = Mock ()
122
122
gist_list = gist .GistListCommand (mocked_window )
123
123
gist_list .handle_gist ({'url' : TEST_GIST_URL })
124
124
mocked_open_gist .assert_called_with (TEST_GIST_URL )
125
125
self .assertEqual (gist_list .get_window (), mocked_window )
126
126
127
- @patch ('gist .insert_gist' )
127
+ @patch ('gist_80 .insert_gist' )
128
128
def test_insert_gist_list_command (self , mocked_insert_gist ):
129
129
mocked_window = Mock ()
130
130
insert_gist_list = gist .InsertGistListCommand (mocked_window )
131
131
insert_gist_list .handle_gist ({'url' : TEST_GIST_URL })
132
132
mocked_insert_gist .assert_called_with (TEST_GIST_URL )
133
133
self .assertEqual (insert_gist_list .get_window (), mocked_window )
134
134
135
- @patch ('gist .insert_gist_embed' )
135
+ @patch ('gist_80 .insert_gist_embed' )
136
136
def test_insert_gist_embed_list_command (self , mocked_insert_gist_embed ):
137
137
mocked_window = Mock ()
138
138
insert_gist_embed_list = gist .InsertGistEmbedListCommand (mocked_window )
139
139
insert_gist_embed_list .handle_gist ({'url' : TEST_GIST_URL })
140
140
mocked_insert_gist_embed .assert_called_with (TEST_GIST_URL )
141
141
self .assertEqual (insert_gist_embed_list .get_window (), mocked_window )
142
142
143
- @patch ('gist .gistify_view' )
144
- @patch ('gist .update_gist' )
143
+ @patch ('gist_80 .gistify_view' )
144
+ @patch ('gist_80 .update_gist' )
145
145
def test_gist_add_file_command (self , mocked_update_gist , mocked_gistify_view ):
146
146
add_file = gist .GistAddFileCommand ()
147
147
add_file .handle_gist ({'url' : TEST_GIST_URL })
@@ -179,9 +179,9 @@ def test_gist_view_command(self):
179
179
self .assertEqual (gist_view_command .gist_filename (), 'some gist filename' )
180
180
self .assertEqual (gist_view_command .gist_description (), 'some gist description' )
181
181
182
- @patch ('gist .gistify_view' )
182
+ @patch ('gist_80 .gistify_view' )
183
183
@patch ('test.stubs.sublime.Region' )
184
- @patch ('gist .create_gist' )
184
+ @patch ('gist_80 .create_gist' )
185
185
def test_gist_command (self , mocked_create_gist , mocked_region , mocked_gistify_view ):
186
186
gist_command = gist .GistCommand ()
187
187
gist_command .view = sublime .View ()
@@ -234,8 +234,8 @@ def test_gist_private_command(self):
234
234
gist_private_command = gist .GistPrivateCommand ()
235
235
self .assertEqual (gist_private_command .mode (), 'Private' )
236
236
237
- @patch ('gist .gistify_view' )
238
- @patch ('gist .update_gist' )
237
+ @patch ('gist_80 .gistify_view' )
238
+ @patch ('gist_80 .update_gist' )
239
239
def test_gist_rename_file_command (self , mocked_update_gist , mocked_gistify_view ):
240
240
gist_rename_file = gist .GistRenameFileCommand ()
241
241
mocked_update_gist .return_value = 'some updated gist'
@@ -254,8 +254,8 @@ def test_gist_rename_file_command(self, mocked_update_gist, mocked_gistify_view)
254
254
mocked_gistify_view .assert_called_with (gist_rename_file .view , 'some updated gist' , 'some new filename' )
255
255
sublime .status_message .assert_called_with ('Gist file renamed' )
256
256
257
- @patch ('gist .gistify_view' )
258
- @patch ('gist .update_gist' )
257
+ @patch ('gist_80 .gistify_view' )
258
+ @patch ('gist_80 .update_gist' )
259
259
def test_change_description_command (self , mocked_update_gist , mocked_gistify_view ):
260
260
sublime ._windows [0 ] = sublime .Window (0 )
261
261
mocked_update_gist .return_value = 'some updated gist'
@@ -274,7 +274,7 @@ def test_change_description_command(self, mocked_update_gist, mocked_gistify_vie
274
274
mocked_gistify_view .assert_called_with (sublime ._windows [0 ]._view , 'some updated gist' , None )
275
275
sublime .status_message .assert_called_with ('Gist description changed' )
276
276
277
- @patch ('gist .update_gist' )
277
+ @patch ('gist_80 .update_gist' )
278
278
def test_gist_update_file_command (self , mocked_update_gist ):
279
279
gist_update_file = gist .GistUpdateFileCommand ()
280
280
gist_update_file .run (edit = False )
@@ -283,8 +283,8 @@ def test_gist_update_file_command(self, mocked_update_gist):
283
283
284
284
sublime .status_message .assert_called_with ('Gist updated' )
285
285
286
- @patch ('gist .ungistify_view' )
287
- @patch ('gist .update_gist' )
286
+ @patch ('gist_80 .ungistify_view' )
287
+ @patch ('gist_80 .update_gist' )
288
288
def test_gist_delete_file_command (self , mocked_update_gist , mocked_ungistify_view ):
289
289
gist_delete_file = gist .GistDeleteFileCommand ()
290
290
gist_delete_file .run (edit = False )
@@ -294,8 +294,8 @@ def test_gist_delete_file_command(self, mocked_update_gist, mocked_ungistify_vie
294
294
295
295
sublime .status_message .assert_called_with ('Gist file deleted' )
296
296
297
- @patch ('gist .ungistify_view' )
298
- @patch ('gist .api_request' )
297
+ @patch ('gist_80 .ungistify_view' )
298
+ @patch ('gist_80 .api_request' )
299
299
def test_gist_delete_command (self , mocked_api_request , mocked_ungistify_view ):
300
300
gist_delete = gist .GistDeleteCommand ()
301
301
gist_delete .run (edit = False )
@@ -305,7 +305,7 @@ def test_gist_delete_command(self, mocked_api_request, mocked_ungistify_view):
305
305
306
306
sublime .status_message .assert_called_with ('Gist deleted' )
307
307
308
- @patch ('gist .update_gist' )
308
+ @patch ('gist_80 .update_gist' )
309
309
def test_gist_listener (self , mocked_update_gist ):
310
310
gist_listener = gist .GistListener ()
311
311
gist .plugin_loaded ()
0 commit comments