diff --git a/bumper/__init__.py b/bumper/__init__.py index f5112c2..fda6461 100644 --- a/bumper/__init__.py +++ b/bumper/__init__.py @@ -982,6 +982,7 @@ def create_certs(): subprocess.run([os.path.join("..", "create_certs", "create_certs_linux")]) else: + os.chdir(odir) logging.log( logging.FATAL, "Can't determine platform. Create certs manually and try again.", @@ -1000,23 +1001,8 @@ def create_certs(): os.execv(sys.executable, ["python"] + sys.argv) # Start again -def firstrun_input(): - return input( - "No certificates found, would you like to create them automatically? (y/n): " - ).lower() - - def first_run(): - yes = {"yes", "y", "ye", ""} - print("") - if firstrun_input() in yes: - create_certs() - - else: - logging.log( - logging.FATAL, - "Can't continue without certificates, please create some then try again.", - ) + create_certs() def main(argv=None): diff --git a/tests/test_init.py b/tests/test_init.py index 88faec4..0e3ca2c 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -41,7 +41,7 @@ async def test_start_stop(): await asyncio.sleep(0.1) l.check_present(("bumper", "INFO", "Starting Bumper")) l.clear() - assert b.shutting_down == False + asyncio.create_task(b.shutdown()) await asyncio.sleep(0.1) l.check_present( diff --git a/tests/test_z_problem.py b/tests/test_z_problem.py index bf93b00..f3f00f2 100644 --- a/tests/test_z_problem.py +++ b/tests/test_z_problem.py @@ -13,29 +13,10 @@ from testfixtures import LogCapture import sys -@patch("bumper.firstrun_input") -@patch("bumper.create_certs") -def test_firstrun(mock_input, mock_create): - with LogCapture() as l: - - bumper.firstrun_input.return_value = "n" - bumper.first_run() - l.check_present( - ( - "root", - "CRITICAL", - "Can't continue without certificates, please create some then try again.", - ) - ) - - bumper.firstrun_input.return_value = "y" - bumper.first_run() - assert mock_create.called == True - - def mock_subrun(*args): return args + @patch("bumper.start") def test_argparse(mock_start): bumper.ca_cert = "tests/test_certs/ca.crt" @@ -70,23 +51,35 @@ def test_createcert(mock_run, mock_platform, mock_machine, mock_exec): platform.system.return_value = "darwin" bumper.create_certs() assert mock_run.called == True - assert os.path.join("..", "create_certs", "create_certs_osx") in mock_exec.call_args.args[0] + assert ( + os.path.join("..", "create_certs", "create_certs_osx") + in mock_exec.call_args.args[0] + ) platform.system.return_value = "windows" bumper.create_certs() assert mock_run.called == True - assert os.path.join("..", "create_certs", "create_certs_windows.exe") in mock_exec.call_args.args[0] + assert ( + os.path.join("..", "create_certs", "create_certs_windows.exe") + in mock_exec.call_args.args[0] + ) platform.system.return_value = "linux" bumper.create_certs() assert mock_run.called == True - assert os.path.join("..", "create_certs","create_certs_linux") in mock_exec.call_args.args[0] + assert ( + os.path.join("..", "create_certs", "create_certs_linux") + in mock_exec.call_args.args[0] + ) platform.system.return_value = "linux" platform.machine.return_value = "arm" bumper.create_certs() assert mock_run.called == True - assert os.path.join("..", "create_certs", "create_certs_rpi") in mock_exec.call_args.args[0] + assert ( + os.path.join("..", "create_certs", "create_certs_rpi") + in mock_exec.call_args.args[0] + ) with LogCapture() as l: platform.system.return_value = "nixbad" @@ -101,7 +94,6 @@ def test_createcert(mock_run, mock_platform, mock_machine, mock_exec): ) - @patch("bumper.first_run") def test_main(mock_firstrun): bumper.ca_cert = "sf"