-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dri-1032): add the ability to support measure (unit group)
- Loading branch information
1 parent
9874d30
commit 90c024e
Showing
7 changed files
with
122 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from unittest.mock import patch | ||
from src.corva_unit_converter.converter import Converter | ||
|
||
|
||
def test_get_measures_returns_correct_keys(): | ||
"""Should return a list of available measures.""" | ||
converter = Converter() | ||
result = converter.get_measures() | ||
|
||
expected_keys = [ | ||
"acoustic_slowness", "angle", "angle_per_length", "angular_velocity", | ||
"area", "density", "energy", "force", "gas_concentration", | ||
"gas_volume", "inverse_pressure", "length", "length_per_angle", | ||
"mass", "mass_flow_rate", "mpl", "porosity", "power", "pressure", | ||
"pressure_gradient", "proportion", "revolution_per_volume", "speed", | ||
"strokes_rate", "temperature", "time", "torque", | ||
"volume_concentration", "volume_flow_rate" | ||
] | ||
|
||
assert sorted(result) == sorted(expected_keys) | ||
|
||
|
||
def test_convert_with_invalid_measure(): | ||
"""Should return None because 'proportions' measure doesn't exist.""" | ||
with patch('logging.info') as mocked_info: | ||
converter = Converter() | ||
result = converter.convert('%', 'Fraction', 1, 'proportios') | ||
|
||
assert result is None | ||
assert mocked_info.called | ||
expected_invalid_measure_msg = ( | ||
f"Invalid measure: proportios. " | ||
f"Available measures are: {converter.get_measures()}" | ||
) | ||
mocked_info.assert_called_with(expected_invalid_measure_msg) |
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
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