77
88
99@pytest .fixture
10- def mock_google_user_exists (mock_google_user_exists ):
11- return mock_google_user_exists (MODULE )
10+ def mock_input_yes (mock_input ):
11+ fix = mock_input (MODULE )
12+ fix .return_value = "y"
13+ return fix
14+
15+
16+ @pytest .fixture
17+ def mock_input_no (mock_input ):
18+ fix = mock_input (MODULE )
19+ fix .return_value = "n"
20+ return fix
1221
1322
1423@pytest .fixture
1524def mock_commands_signout (mock_commands_signout ):
1625 return mock_commands_signout (MODULE )
1726
1827
28+ @pytest .fixture
29+ def mock_google_user_exists (mock_google_user_exists ):
30+ return mock_google_user_exists (MODULE )
31+
32+
1933@pytest .fixture
2034def mock_google_CallGAMCommand (mock_google_CallGAMCommand ):
2135 return mock_google_CallGAMCommand (MODULE )
@@ -37,10 +51,34 @@ def test_reset_user_does_not_exist(mock_google_user_exists):
3751 assert res == RESULT_FAILURE
3852
3953
54+ @pytest .mark .usefixtures ("mock_input_yes" )
55+ def test_reset_confirm_yes (mock_google_user_exists , mock_google_CallGAMCommand , mock_commands_signout ):
56+ mock_google_user_exists .return_value = True
57+
58+ args = Namespace (username = "username" , force = False )
59+ res = reset (args )
60+
61+ assert res == RESULT_SUCCESS
62+ mock_google_CallGAMCommand .assert_called_once ()
63+ mock_commands_signout .assert_called_once_with (args )
64+
65+
66+ @pytest .mark .usefixtures ("mock_input_no" )
67+ def test_reset_confirm_no (mock_google_user_exists , mock_google_CallGAMCommand , mock_commands_signout ):
68+ mock_google_user_exists .return_value = True
69+
70+ args = Namespace (username = "username" , force = False )
71+ res = reset (args )
72+
73+ assert res == RESULT_SUCCESS
74+ mock_google_CallGAMCommand .assert_not_called ()
75+ mock_commands_signout .assert_not_called ()
76+
77+
4078def test_reset_user_exists (mock_google_user_exists , mock_google_CallGAMCommand , mock_commands_signout ):
4179 mock_google_user_exists .return_value = True
4280
43- args = Namespace (username = "username" )
81+ args = Namespace (username = "username" , force = True )
4482 res = reset (args )
4583
4684 assert res == RESULT_SUCCESS
@@ -56,7 +94,7 @@ def test_reset_user_exists(mock_google_user_exists, mock_google_CallGAMCommand,
5694def test_reset_notify (mock_google_user_exists , mock_google_CallGAMCommand , mock_commands_signout ):
5795 mock_google_user_exists .return_value = True
5896
59- args = Namespace (username = "username" , notify = "notification@example.com" )
97+ args = Namespace (username = "username" , notify = "notification@example.com" , force = True )
6098 res = reset (args )
6199
62100 assert res == RESULT_SUCCESS
0 commit comments