Added docstrings and test for updater.find_datafiles

This commit is contained in:
Manuel Cortez 2022-02-18 12:40:07 -06:00
parent edca670a52
commit e4c953e5b6
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
2 changed files with 23 additions and 1 deletions

16
test/test_module.py Normal file
View File

@ -0,0 +1,16 @@
import os
import pytest
import updater
from unittest import mock
@pytest.mark.parametrize("system", [("Windows", "Linux", "Darwin")])
def test_find_datafiles(system):
with mock.patch("platform.system", return_value=system):
result = updater.find_datafiles()
if system == "Windows":
assert "bootstrap.exe" in result[0][1]
assert os.path.exists(result[0][1][0])
else:
assert len(result[0][1]) == 2
assert os.path.exists(result[0][1][0])
assert os.path.exists(result[0][1][1])

View File

@ -1,8 +1,14 @@
import glob
import os.path
import platform
from typing import List, Tuple
def find_datafiles():
def find_datafiles() -> List[Tuple[str, List[str]]]:
""" Returns path to the updater bootstrap file.
:returns: A tuple of the form ("", ["bootstrap_file"])
:rtype: tuple
"""
system = platform.system()
if system == 'Windows':
file_ext = '*.exe'