Skip to content

Commit

Permalink
NXDRIVE-2860: Code Coverage - added two testcases in test_api.py
Browse files Browse the repository at this point in the history
  • Loading branch information
gitofanindya committed Nov 23, 2023
1 parent 6eb286c commit 4c26efb
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions tests/functional/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,55 @@ def mocked_open_authentication_dialog():
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 "Report"

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 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:
from nxdrive import utils

with patch.object(utils, "disk_space", new=func):
returned_val = drive_api.get_disk_space_info_to_width(
"001", "dummy_path", 100
)
assert returned_val

0 comments on commit 4c26efb

Please sign in to comment.