File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change 99import pytest
1010import structlog .testing
1111
12- from power_grid_model_io .utils .zip import extract
12+ from power_grid_model_io .utils .zip import _get_only_item_in_dir , extract
1313
1414from ...utils import MockTqdm , assert_log_exists
1515
@@ -123,3 +123,36 @@ def test_extract__return_subdir_path(mock_tqdm: MagicMock, temp_dir: Path):
123123 # Assert
124124 assert extract_dir_path == temp_dir / "foo" / "foo"
125125 assert (temp_dir / "foo" / "foo" / "foo.txt" ).is_file ()
126+
127+
128+ def test_get_only_item_in_dir__no_items (temp_dir ):
129+ # Act / Assert
130+ assert _get_only_item_in_dir (temp_dir ) == None
131+
132+
133+ def test_get_only_item_in_dir__one_file (temp_dir ):
134+ # Arrange
135+ with open (temp_dir / "file.txt" , "wb" ):
136+ pass
137+
138+ # Act / Assert
139+ assert _get_only_item_in_dir (temp_dir ) == temp_dir / "file.txt"
140+
141+
142+ def test_get_only_item_in_dir__one_dir (temp_dir ):
143+ # Arrange
144+ (temp_dir / "subdir" ).mkdir ()
145+
146+ # Act / Assert
147+ assert _get_only_item_in_dir (temp_dir ) == temp_dir / "subdir"
148+
149+
150+ def test_get_only_item_in_dir__two_files (temp_dir ):
151+ # Arrange
152+ with open (temp_dir / "file_1.txt" , "wb" ):
153+ pass
154+ with open (temp_dir / "file_2.txt" , "wb" ):
155+ pass
156+
157+ # Act / Assert
158+ assert _get_only_item_in_dir (temp_dir ) == None
You can’t perform that action at this time.
0 commit comments