-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ainur Karimov
committed
Dec 20, 2024
1 parent
a4bce08
commit 8295047
Showing
5 changed files
with
63 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from unittest.mock import patch | ||
import argparse | ||
|
||
from innofw.utils.data_utils.preprocessing.CT_hemorrhage_contrast_rtk import ( | ||
callback, | ||
default_output_path, | ||
setup_parser, | ||
) | ||
|
||
|
||
def test_setup_parser(): | ||
parser = argparse.ArgumentParser() | ||
setup_parser(parser) | ||
args = parser.parse_args(["-i", "input.txt"]) | ||
assert args.input == "input.txt" | ||
assert args.output is None | ||
|
||
args = parser.parse_args(["-i", "input.txt", "-o", "output.txt"]) | ||
assert args.input == "input.txt" | ||
assert args.output == "output.txt" | ||
|
||
|
||
def test_default_output_path(): | ||
# Mock get_log_dir to return a predictable value | ||
with patch("innofw.utils.getters.get_log_dir", return_value="mock_log_dir"): | ||
output_path = default_output_path() | ||
assert output_path == "mock_log_dir" | ||
|
||
|
||
@patch("innofw.utils.data_utils.preprocessing.CT_hemorrhage_contrast_rtk.hemorrhage_contrast") | ||
def test_callback_success(mock_contrast): | ||
arguments = argparse.Namespace(input="input.txt", output="output.txt") | ||
callback(arguments) | ||
mock_contrast.assert_called_once_with("input.txt", "output.txt") |
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,22 @@ | ||
import argparse | ||
from unittest.mock import patch | ||
|
||
from innofw.utils.data_utils.rtk.lungs_description_metrics import ( | ||
callback, | ||
setup_parser, | ||
) | ||
|
||
|
||
def test_setup_parser(): | ||
parser = argparse.ArgumentParser() | ||
setup_parser(parser) | ||
args = parser.parse_args(["-i", "input.txt", "-o", "output.txt"]) | ||
assert args.input == "input.txt" | ||
assert args.output == "output.txt" | ||
|
||
|
||
@patch("innofw.utils.data_utils.rtk.lungs_description_metrics.calculate_lungs_metrics") | ||
def test_callback_success(mock_calc): | ||
arguments = argparse.Namespace(input="input.txt", output="output.txt") | ||
callback(arguments) | ||
mock_calc.assert_called_once_with("input.txt", "output.txt") |
File renamed without changes.