8
8
# local lib
9
9
from jupyterlab_git .git import Git
10
10
11
- from .testutils import FakeContentManager
11
+ from .testutils import FakeContentManager , maybe_future
12
12
13
13
14
14
def test_is_remote_branch ():
@@ -33,7 +33,7 @@ async def test_get_current_branch_success():
33
33
34
34
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
35
35
# Given
36
- mock_execute .return_value = tornado . gen . maybe_future ((0 , "feature-foo" , "" ))
36
+ mock_execute .return_value = maybe_future ((0 , "feature-foo" , "" ))
37
37
38
38
# When
39
39
actual_response = await (
@@ -59,10 +59,10 @@ async def test_checkout_branch_noref_success():
59
59
60
60
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
61
61
with patch .object (
62
- Git , "_get_branch_reference" , return_value = tornado . gen . maybe_future (None )
62
+ Git , "_get_branch_reference" , return_value = maybe_future (None )
63
63
) as mock__get_branch_reference :
64
64
# Given
65
- mock_execute .return_value = tornado . gen . maybe_future (
65
+ mock_execute .return_value = maybe_future (
66
66
(rc , stdout_message , stderr_message )
67
67
)
68
68
@@ -93,10 +93,10 @@ async def test_checkout_branch_noref_failure():
93
93
rc = 1
94
94
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
95
95
with patch .object (
96
- Git , "_get_branch_reference" , return_value = tornado . gen . maybe_future (None )
96
+ Git , "_get_branch_reference" , return_value = maybe_future (None )
97
97
) as mock__get_branch_reference :
98
98
# Given
99
- mock_execute .return_value = tornado . gen . maybe_future (
99
+ mock_execute .return_value = maybe_future (
100
100
(rc , stdout_message , stderr_message )
101
101
)
102
102
@@ -132,10 +132,10 @@ async def test_checkout_branch_remoteref_success():
132
132
with patch .object (
133
133
Git ,
134
134
"_get_branch_reference" ,
135
- return_value = tornado . gen . maybe_future ("refs/remotes/remote_branch" ),
135
+ return_value = maybe_future ("refs/remotes/remote_branch" ),
136
136
) as mock__get_branch_reference :
137
137
# Given
138
- mock_execute .return_value = tornado . gen . maybe_future (
138
+ mock_execute .return_value = maybe_future (
139
139
(rc , stdout_message , stderr_message )
140
140
)
141
141
@@ -169,10 +169,10 @@ async def test_checkout_branch_headsref_failure():
169
169
with patch .object (
170
170
Git ,
171
171
"_get_branch_reference" ,
172
- return_value = tornado . gen . maybe_future ("refs/heads/local_branch" ),
172
+ return_value = maybe_future ("refs/heads/local_branch" ),
173
173
) as mock__get_branch_reference :
174
174
# Given
175
- mock_execute .return_value = tornado . gen . maybe_future (
175
+ mock_execute .return_value = maybe_future (
176
176
(rc , stdout_message , stderr_message )
177
177
)
178
178
@@ -206,10 +206,10 @@ async def test_checkout_branch_headsref_success():
206
206
with patch .object (
207
207
Git ,
208
208
"_get_branch_reference" ,
209
- return_value = tornado . gen . maybe_future ("refs/heads/local_branch" ),
209
+ return_value = maybe_future ("refs/heads/local_branch" ),
210
210
):
211
211
# Given
212
- mock_execute .return_value = tornado . gen . maybe_future (
212
+ mock_execute .return_value = maybe_future (
213
213
(rc , stdout_message , stderr_message )
214
214
)
215
215
@@ -239,10 +239,10 @@ async def test_checkout_branch_remoteref_failure():
239
239
with patch .object (
240
240
Git ,
241
241
"_get_branch_reference" ,
242
- return_value = tornado . gen . maybe_future ("refs/remotes/remote_branch" ),
242
+ return_value = maybe_future ("refs/remotes/remote_branch" ),
243
243
):
244
244
# Given
245
- mock_execute .return_value = tornado . gen . maybe_future (
245
+ mock_execute .return_value = maybe_future (
246
246
(rc , stdout_message , stderr_message )
247
247
)
248
248
@@ -272,7 +272,7 @@ async def test_get_branch_reference_success():
272
272
branch = "test-branch"
273
273
reference = "refs/remotes/origin/test_branch"
274
274
275
- mock_execute .return_value = tornado . gen . maybe_future ((0 , reference , "" ))
275
+ mock_execute .return_value = maybe_future ((0 , reference , "" ))
276
276
277
277
# When
278
278
actual_response = await Git (FakeContentManager ("/bin" ))._get_branch_reference (
@@ -294,7 +294,7 @@ async def test_get_branch_reference_failure():
294
294
branch = "test-branch"
295
295
reference = "test-branch"
296
296
# Given
297
- mock_execute .return_value = tornado . gen . maybe_future (
297
+ mock_execute .return_value = maybe_future (
298
298
(
299
299
128 ,
300
300
reference ,
@@ -321,7 +321,7 @@ async def test_get_branch_reference_failure():
321
321
async def test_get_current_branch_failure ():
322
322
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
323
323
# Given
324
- mock_execute .return_value = tornado . gen . maybe_future (
324
+ mock_execute .return_value = maybe_future (
325
325
(
326
326
128 ,
327
327
"" ,
@@ -356,7 +356,7 @@ async def test_get_current_branch_detached_success():
356
356
" remotes/origin/feature-foo" ,
357
357
" remotes/origin/HEAD" ,
358
358
]
359
- mock_execute .return_value = tornado . gen . maybe_future (
359
+ mock_execute .return_value = maybe_future (
360
360
(0 , "\n " .join (process_output ), "" )
361
361
)
362
362
@@ -376,7 +376,7 @@ async def test_get_current_branch_detached_success():
376
376
async def test_get_current_branch_detached_failure ():
377
377
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
378
378
# Given
379
- mock_execute .return_value = tornado . gen . maybe_future (
379
+ mock_execute .return_value = maybe_future (
380
380
(
381
381
128 ,
382
382
"" ,
@@ -413,7 +413,7 @@ async def test_get_current_branch_detached_failure():
413
413
async def test_get_upstream_branch_success (branch , upstream ):
414
414
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
415
415
# Given
416
- mock_execute .return_value = tornado . gen . maybe_future ((0 , upstream , "" ))
416
+ mock_execute .return_value = maybe_future ((0 , upstream , "" ))
417
417
418
418
# When
419
419
actual_response = await Git (FakeContentManager ("/bin" )).get_upstream_branch (
@@ -451,7 +451,7 @@ async def test_get_upstream_branch_success(branch, upstream):
451
451
async def test_get_upstream_branch_failure (outputs , message ):
452
452
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
453
453
# Given
454
- mock_execute .return_value = tornado . gen . maybe_future (outputs )
454
+ mock_execute .return_value = maybe_future (outputs )
455
455
456
456
# When
457
457
if message :
@@ -482,7 +482,7 @@ async def test_get_upstream_branch_failure(outputs, message):
482
482
async def test_get_tag_success ():
483
483
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
484
484
# Given
485
- mock_execute .return_value = tornado . gen . maybe_future ((0 , "v0.3.0" , "" ))
485
+ mock_execute .return_value = maybe_future ((0 , "v0.3.0" , "" ))
486
486
487
487
# When
488
488
actual_response = await Git (FakeContentManager ("/bin" ))._get_tag (
@@ -503,8 +503,8 @@ async def test_get_tag_failure():
503
503
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
504
504
# Given
505
505
mock_execute .side_effect = [
506
- tornado . gen . maybe_future ((128 , "" , "fatal: Not a valid object name blah" )),
507
- tornado . gen . maybe_future (
506
+ maybe_future ((128 , "" , "fatal: Not a valid object name blah" )),
507
+ maybe_future (
508
508
(
509
509
128 ,
510
510
"" ,
@@ -557,7 +557,7 @@ async def test_get_tag_failure():
557
557
async def test_no_tags ():
558
558
with patch ("jupyterlab_git.git.execute" ) as mock_execute :
559
559
# Given
560
- mock_execute .return_value = tornado . gen . maybe_future (
560
+ mock_execute .return_value = maybe_future (
561
561
(128 , "" , "fatal: No names found, cannot describe anything.\n " )
562
562
)
563
563
@@ -590,9 +590,9 @@ async def test_branch_success():
590
590
591
591
mock_execute .side_effect = [
592
592
# Response for get all refs/heads
593
- tornado . gen . maybe_future ((0 , "\n " .join (process_output_heads ), "" )),
593
+ maybe_future ((0 , "\n " .join (process_output_heads ), "" )),
594
594
# Response for get all refs/remotes
595
- tornado . gen . maybe_future ((0 , "\n " .join (process_output_remotes ), "" )),
595
+ maybe_future ((0 , "\n " .join (process_output_remotes ), "" )),
596
596
]
597
597
598
598
expected_response = {
@@ -694,7 +694,7 @@ async def test_branch_failure():
694
694
"--format=%(refname:short)%09%(objectname)%09%(upstream:short)%09%(HEAD)" ,
695
695
"refs/heads/" ,
696
696
]
697
- mock_execute .return_value = tornado . gen . maybe_future (
697
+ mock_execute .return_value = maybe_future (
698
698
(
699
699
128 ,
700
700
"" ,
@@ -738,15 +738,15 @@ async def test_branch_success_detached_head():
738
738
739
739
mock_execute .side_effect = [
740
740
# Response for get all refs/heads
741
- tornado . gen . maybe_future ((0 , "\n " .join (process_output_heads ), "" )),
741
+ maybe_future ((0 , "\n " .join (process_output_heads ), "" )),
742
742
# Response for get current branch
743
- tornado . gen . maybe_future (
743
+ maybe_future (
744
744
(128 , "" , "fatal: ref HEAD is not a symbolic ref" )
745
745
),
746
746
# Response for get current branch detached
747
- tornado . gen . maybe_future ((0 , "\n " .join (detached_head_output ), "" )),
747
+ maybe_future ((0 , "\n " .join (detached_head_output ), "" )),
748
748
# Response for get all refs/remotes
749
- tornado . gen . maybe_future ((0 , "\n " .join (process_output_remotes ), "" )),
749
+ maybe_future ((0 , "\n " .join (process_output_remotes ), "" )),
750
750
]
751
751
752
752
expected_response = {
0 commit comments