From 3bf7738ddf4f9ccaffbf143f391c81ad38005bc3 Mon Sep 17 00:00:00 2001 From: Anindya Roy Date: Mon, 20 Nov 2023 10:36:59 +0530 Subject: [PATCH] 002 --- tests/functional/test_api.py | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/tests/functional/test_api.py b/tests/functional/test_api.py index a1d7a14ead..c78fb16fd1 100644 --- a/tests/functional/test_api.py +++ b/tests/functional/test_api.py @@ -32,3 +32,71 @@ def mocked_open_authentication_dialog(): True, ) assert not returned_val + + +def test_get_features_list(manager_factory): + manager = manager_factory(with_engine=False) + manager.application = "" + + def mocked_open_authentication_dialog(): + return + + Mocked_App = namedtuple( + "app", + "manager, open_authentication_dialog", + defaults=(manager, mocked_open_authentication_dialog), + ) + app = Mocked_App() + drive_api = QMLDriveApi(app) + + with manager: + returned_val = drive_api.get_features_list() + assert returned_val + + +def test_generate_report(manager_factory): + manager = manager_factory(with_engine=False) + manager.application = "" + + def mocked_open_authentication_dialog(): + return + + def func(*args): + return 1 / 0 + + Mocked_App = namedtuple( + "app", + "manager, open_authentication_dialog", + defaults=(manager, mocked_open_authentication_dialog), + ) + app = Mocked_App() + drive_api = QMLDriveApi(app) + + with manager: + with patch.object(manager, "generate_report", new=func): + returned_val = drive_api.generate_report() + assert not returned_val + + +def test_get_disk_space_info_to_width(manager_factory): + manager, engine = manager_factory() + manager.application = "" + + def mocked_open_authentication_dialog(): + return + + def func(*args): + return 100, 200 + + Mocked_App = namedtuple( + "app", + "manager, open_authentication_dialog", + defaults=(manager, mocked_open_authentication_dialog), + ) + app = Mocked_App() + drive_api = QMLDriveApi(app) + + with manager: + with patch.object(engine, "disk_space", new=func): + returned_val = drive_api.get_disk_space_info_to_width() + assert not returned_val