Example #1
0
File: env.py Project: junaruga/pcs
    def flush(modified_env):
        if not is_mocked_environment:
            return
        if not modified_env:
            #TODO now this would not happen
            #for more information see comment in
            #pcs.cli.common.lib_wrapper.lib_env_to_cli_env
            raise console_report.error("Error during library communication")

        env_file.process_no_existing_file_expectation(
            "booth config file", modified_env["config_file"], config_path)
        env_file.process_no_existing_file_expectation("booth key file",
                                                      modified_env["key_file"],
                                                      key_path)
        env_file.write(modified_env["key_file"], key_path)
        env_file.write(modified_env["config_file"], config_path)
Example #2
0
 def test_exit_when_cannot_open_file(self):
     self.mock_open.side_effect = EnvironmentError()
     self.mock_error.side_effect = SystemExit()
     self.assertRaises(
         SystemExit,
         lambda: env_file.write({"content": "filecontent"}, FILE_PATH)
     )
Example #3
0
 def test_exit_when_cannot_open_file(self):
     self.mock_open.side_effect = EnvironmentError()
     self.mock_error.side_effect = SystemExit()
     self.assertRaises(
         SystemExit,
         lambda: env_file.write({"content": "filecontent"}, FILE_PATH)
     )
Example #4
0
    def flush(modified_env):
        if not is_mocked_environment:
            return
        if not modified_env:
            #TODO now this would not happen
            #for more information see comment in
            #pcs.cli.common.lib_wrapper.lib_env_to_cli_env
            raise console_report.error("Error during library communication")

        env_file.process_no_existing_file_expectation(
            "booth config file",
            modified_env["config_file"],
            config_path
        )
        env_file.process_no_existing_file_expectation(
            "booth key file",
            modified_env["key_file"],
            key_path
        )
        env_file.write(modified_env["key_file"], key_path)
        env_file.write(modified_env["config_file"], config_path)
Example #5
0
 def assert_params_causes_calls(self, env_file_dict, calls, path=FILE_PATH):
     with patch_env_file("open", self.mock_open, create=True):
         env_file.write(env_file_dict, path)
     self.assertEqual(self.mock_open.mock_calls, calls)
Example #6
0
 def assert_params_causes_calls(self, env_file_dict, calls, path=FILE_PATH):
     with patch_env_file("open", self.mock_open, create=True):
         env_file.write(env_file_dict, path)
     self.assertEqual(self.mock_open.mock_calls, calls)