-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #162 from rakuri255/refactor/class-refactorings
Refactor/class refactorings
- Loading branch information
Showing
38 changed files
with
2,286 additions
and
1,121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...les/UltraStar/test_ultrastar_converter.py → ...tar/converter/test_ultrastar_converter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
pytest/modules/UltraStar/converter/test_ultrastar_txt_converter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
"""Tests for ultrastar_txt_converter.py""" | ||
|
||
import unittest | ||
from modules.Ultrastar.coverter.ultrastar_txt_converter import extract_year | ||
|
||
|
||
class TestUltrastarTxtConverter(unittest.TestCase): | ||
|
||
def test_extract_year(self): | ||
years = {extract_year("2023-12-31"), extract_year("2023-12-31 23:59:59"), extract_year("2023/12/31"), | ||
extract_year("2023\\12\\31"), extract_year("2023.12.31"), extract_year("2023 12 31"), | ||
extract_year("12-31-2023"), extract_year("12/31/2023"), extract_year("12\\31\\2023"), | ||
extract_year("12.31.2023"), extract_year("12 31 2023"), extract_year("12-2023"), | ||
extract_year("12/2023"), extract_year("2023")} | ||
|
||
for year in years: | ||
self.assertEqual(year, "2023") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"""Tests for ultrastar_parser.py""" | ||
|
||
import unittest | ||
import os | ||
from unittest.mock import patch, MagicMock | ||
from modules.Ultrastar.ultrastar_parser import parse_ultrastar_txt | ||
|
||
|
||
class TestUltraStarParser(unittest.TestCase): | ||
@patch("modules.Ultrastar.ultrastar_parser.parse") | ||
@patch("modules.Ultrastar.ultrastar_parser.os.path.dirname") | ||
@patch("modules.os_helper.create_folder") | ||
def test_parse_ultrastar_txt(self, mock_create_folder, mock_dirname, mock_parse): | ||
# Arrange | ||
mock_parse.return_value = MagicMock(mp3="test.mp3", | ||
artist=" Test Artist ", | ||
# Also test leading and trailing whitespaces | ||
title=" Test Title ") # Also test leading and trailing whitespaces | ||
|
||
mock_dirname.return_value = os.path.join("path", "to", "input") | ||
output_file_path = os.path.join("path", "to", "output") | ||
|
||
mock_create_folder.return_value = None | ||
|
||
# Act | ||
result = parse_ultrastar_txt(mock_dirname.return_value, output_file_path) | ||
|
||
# Assert | ||
self.assertEqual(result, ("Test Artist - Test Title", | ||
os.path.join("path", "to", "output", "Test Artist - Test Title"), | ||
os.path.join("path", "to", "input", "test.mp3"), | ||
mock_parse.return_value)) | ||
# | ||
mock_parse.assert_called_once() | ||
mock_dirname.assert_called_once() | ||
mock_create_folder.assert_called_once() |
Oops, something went wrong.