diff --git a/.pylintrc b/.pylintrc index 67fb5ce..cccd319 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,3 +1,3 @@ [MASTER] init-hook="from pylint.config import find_pylintrc; import os, sys; sys.path.append(os.path.dirname(find_pylintrc()))" -disable= \ No newline at end of file +disable=C0301,C0116,W0718 \ No newline at end of file diff --git a/src/main.py b/src/main.py index 325714c..dc38656 100644 --- a/src/main.py +++ b/src/main.py @@ -20,13 +20,13 @@ def main(): sport = ask_sport() - logger.info(f"Selected sport: {sport}") + logger.info(f"Selected sport: %s", sport) file_location = ask_file_location() if file_location == "Download": activity_id = ask_activity_id() - logger.info(f"Selected activity ID: {activity_id}") + logger.info(f"Selected activity ID: %s", activity_id) logger.info("Downloading the TCX file from Strava") download_tcx_file(activity_id, sport) @@ -142,7 +142,7 @@ def indent_xml_file(file_path: str) -> None: with open(file_path, "w", encoding='utf-8') as xml_file: xml_file.write(xml_dom.toprettyxml(indent=" ")) - except Exception as err: + except Exception: logger.warning( "Failed to indent the XML file. The file will be saved without indentation." ) diff --git a/tests/test_main.py b/tests/test_main.py index 524fbd9..302ce41 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,7 +1,21 @@ +import os import unittest -from unittest.mock import MagicMock, patch - -from src.main import * +from unittest.mock import patch + +from src.main import ( + download_tcx_file, + read_xml_file, + modify_xml_header, + write_xml_file, + format_to_swim, + validate_tcx_file, + indent_xml_file, + main, + ask_sport, + ask_file_location, + ask_activity_id, + ask_file_path +) class TestMain(unittest.TestCase): @@ -108,11 +122,11 @@ def test_indent_xml_file(self): def test_indent_xml_file_error(self): file_path = "assets/test.xml" - with patch('src.main.parseString') as mock_parseString: - mock_parseString.return_value = Exception("Error") + with patch('src.main.parseString') as mock_parse_string: + mock_parse_string.return_value = Exception("Error") indent_xml_file(file_path) - self.assertTrue(mock_parseString.called) + self.assertTrue(mock_parse_string.called) @patch('src.main.ask_sport') @patch('src.main.ask_file_location')