Skip to content

Commit

Permalink
refactor: pylint advice
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucs1590 committed Apr 11, 2024
1 parent fed1178 commit 340f829
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -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=
disable=C0301,C0116,W0718
6 changes: 3 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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."
)
Expand Down
26 changes: 20 additions & 6 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 340f829

Please sign in to comment.