5
5
from compiler_admin .commands .signout import signout , __name__ as MODULE
6
6
7
7
8
+ @pytest .fixture
9
+ def mock_input_yes (mock_input ):
10
+ fix = mock_input (MODULE )
11
+ fix .return_value = "y"
12
+ return fix
13
+
14
+
15
+ @pytest .fixture
16
+ def mock_input_no (mock_input ):
17
+ fix = mock_input (MODULE )
18
+ fix .return_value = "n"
19
+ return fix
20
+
21
+
8
22
@pytest .fixture
9
23
def mock_google_user_exists (mock_google_user_exists ):
10
24
return mock_google_user_exists (MODULE )
@@ -22,7 +36,8 @@ def test_signout_user_username_required():
22
36
signout (args )
23
37
24
38
25
- def test_signout_user_exists (mock_google_user_exists , mock_google_CallGAMCommand ):
39
+ @pytest .mark .usefixtures ("mock_input_yes" )
40
+ def test_signout_confirm_yes (mock_google_user_exists , mock_google_CallGAMCommand ):
26
41
mock_google_user_exists .return_value = True
27
42
28
43
args = Namespace (username = "username" )
@@ -34,11 +49,22 @@ def test_signout_user_exists(mock_google_user_exists, mock_google_CallGAMCommand
34
49
assert "user" in call_args and "signout" in call_args
35
50
36
51
52
+ @pytest .mark .usefixtures ("mock_input_no" )
53
+ def test_signout_confirm_no (mock_google_user_exists , mock_google_CallGAMCommand ):
54
+ mock_google_user_exists .return_value = True
55
+
56
+ args = Namespace (username = "username" )
57
+ res = signout (args )
58
+
59
+ assert res == RESULT_SUCCESS
60
+ mock_google_CallGAMCommand .assert_not_called ()
61
+
62
+
37
63
def test_signout_user_does_not_exist (mock_google_user_exists , mock_google_CallGAMCommand ):
38
64
mock_google_user_exists .return_value = False
39
65
40
66
args = Namespace (username = "username" )
41
67
res = signout (args )
42
68
43
69
assert res == RESULT_FAILURE
44
- assert mock_google_CallGAMCommand .call_count == 0
70
+ mock_google_CallGAMCommand .assert_not_called ()
0 commit comments