@@ -64,7 +64,6 @@ def harness():
6464
6565def test_on_install (harness ):
6666 with (
67- patch ("charm.subprocess.check_call" ) as _check_call ,
6867 patch ("charm.snap.SnapCache" ) as _snap_cache ,
6968 patch ("charm.PostgresqlOperatorCharm._install_snap_package" ) as _install_snap_package ,
7069 patch (
@@ -88,45 +87,6 @@ def test_on_install(harness):
8887 pg_snap .alias .assert_any_call ("psql" )
8988 pg_snap .alias .assert_any_call ("patronictl" )
9089
91- assert _check_call .call_count == 3
92- _check_call .assert_any_call (["mkdir" , "-p" , "/home/_daemon_" ])
93- _check_call .assert_any_call (["chown" , "_daemon_:_daemon_" , "/home/_daemon_" ])
94- _check_call .assert_any_call (["usermod" , "-d" , "/home/_daemon_" , "_daemon_" ])
95-
96- # Assert the status set by the event handler.
97- assert isinstance (harness .model .unit .status , WaitingStatus )
98-
99-
100- def test_on_install_failed_to_create_home (harness ):
101- with (
102- patch ("charm.subprocess.check_call" ) as _check_call ,
103- patch ("charm.snap.SnapCache" ) as _snap_cache ,
104- patch ("charm.PostgresqlOperatorCharm._install_snap_package" ) as _install_snap_package ,
105- patch (
106- "charm.PostgresqlOperatorCharm._reboot_on_detached_storage"
107- ) as _reboot_on_detached_storage ,
108- patch (
109- "charm.PostgresqlOperatorCharm._is_storage_attached" ,
110- side_effect = [False , True , True ],
111- ) as _is_storage_attached ,
112- patch ("charm.logger.exception" ) as _logger_exception ,
113- ):
114- # Test without storage.
115- harness .charm .on .install .emit ()
116- _reboot_on_detached_storage .assert_called_once ()
117- pg_snap = _snap_cache .return_value [charm_refresh .snap_name ()]
118- _check_call .side_effect = [subprocess .CalledProcessError (- 1 , ["test" ])]
119-
120- # Test without adding Patroni resource.
121- harness .charm .on .install .emit ()
122- # Assert that the needed calls were made.
123- _install_snap_package .assert_called_once_with (revision = None )
124- assert pg_snap .alias .call_count == 2
125- pg_snap .alias .assert_any_call ("psql" )
126- pg_snap .alias .assert_any_call ("patronictl" )
127-
128- _logger_exception .assert_called_once_with ("Unable to create _daemon_ home dir" )
129-
13090 # Assert the status set by the event handler.
13191 assert isinstance (harness .model .unit .status , WaitingStatus )
13292
0 commit comments