Skip to content

Commit 0d25ba0

Browse files
committed
Rename tests to mostly match dir structure
1 parent 2f86f57 commit 0d25ba0

27 files changed

Lines changed: 361 additions & 330 deletions

tests/cli/contracts/test_cli_contracts_check.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def mock_contract_metadata() -> dict[str, Any]:
7474

7575
@patch("scribe_data.cli.contracts.check.check_contract_data_completeness")
7676
@patch("scribe_data.cli.contracts.check.print_missing_forms")
77-
def test_check_contracts_with_dir(
77+
def test_cli_contracts_with_dir(
7878
mock_print: MagicMock, mock_check: MagicMock, mock_export_dir: Path
7979
) -> None:
8080
"""
@@ -90,7 +90,7 @@ def test_check_contracts_with_dir(
9090

9191
@patch("scribe_data.cli.contracts.check.check_contract_data_completeness")
9292
@patch("scribe_data.cli.contracts.check.print_missing_forms")
93-
def test_check_contracts_default_dir(
93+
def test_cli_contracts_default_dir(
9494
mock_print: MagicMock, mock_check: MagicMock
9595
) -> None:
9696
"""
@@ -108,7 +108,7 @@ def test_check_contracts_default_dir(
108108

109109

110110
@patch("scribe_data.cli.contracts.check.Path")
111-
def test_check_contracts_nonexistent_dir(mock_path: MagicMock) -> None:
111+
def test_cli_contracts_nonexistent_dir(mock_path: MagicMock) -> None:
112112
"""
113113
Test check_contracts with a nonexistent directory.
114114
"""
@@ -125,7 +125,7 @@ def test_check_contracts_nonexistent_dir(mock_path: MagicMock) -> None:
125125
@patch("scribe_data.cli.contracts.check.data_contracts_langs", ["English"])
126126
@patch("scribe_data.cli.contracts.check.get_language_iso")
127127
@patch("scribe_data.cli.contracts.check.filter_contract_metadata")
128-
def test_check_contract_data_completeness_json_error(
128+
def test_cli_contracts_data_completeness_json_error(
129129
mock_filter_metadata: MagicMock,
130130
mock_get_iso: MagicMock,
131131
mock_export_dir: Path,
@@ -148,7 +148,7 @@ def test_check_contract_data_completeness_json_error(
148148
assert "Error reading" in mock_print.call_args[0][0]
149149

150150

151-
def test_print_missing_forms_none() -> None:
151+
def test_cli_contracts_print_missing_forms_none() -> None:
152152
"""
153153
Test print_missing_forms with no missing forms.
154154
"""
@@ -161,7 +161,7 @@ def test_print_missing_forms_none() -> None:
161161
)
162162

163163

164-
def test_print_missing_forms_with_missing() -> None:
164+
def test_cli_contracts_print_missing_forms_with_missing() -> None:
165165
"""
166166
Test print_missing_forms with missing forms.
167167
"""

tests/cli/contracts/test_cli_contracts_export.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def contracts_source(tmp_path: Path) -> Path:
2424
return source
2525

2626

27-
def test_export_contracts_fresh_export(tmp_path: Path, contracts_source: Path) -> None:
27+
def test_cli_contracts_export_new(tmp_path: Path, contracts_source: Path) -> None:
2828
"""
2929
Test fresh export when no existing contracts folder.
3030
"""
@@ -41,7 +41,7 @@ def test_export_contracts_fresh_export(tmp_path: Path, contracts_source: Path) -
4141
assert (output_dir / "de.yaml").exists()
4242

4343

44-
def test_export_contracts_success_message(
44+
def test_cli_contracts_export_success(
4545
tmp_path: Path, contracts_source: Path, capsys
4646
) -> None:
4747
"""
@@ -59,7 +59,7 @@ def test_export_contracts_success_message(
5959
assert "successfully exported" in captured.out.lower()
6060

6161

62-
def test_export_contracts_overwrite_confirmed(
62+
def test_cli_contracts_export_overwrite_confirmed(
6363
tmp_path: Path, contracts_source: Path
6464
) -> None:
6565
"""
@@ -82,7 +82,7 @@ def test_export_contracts_overwrite_confirmed(
8282
assert not (output_dir / "old.yaml").exists()
8383

8484

85-
def test_export_contracts_overwrite_declined(
85+
def test_cli_contracts_export_overwrite_declined(
8686
tmp_path: Path, contracts_source: Path, capsys
8787
) -> None:
8888
"""
@@ -106,7 +106,7 @@ def test_export_contracts_overwrite_declined(
106106
assert (output_dir / "old.yaml").exists()
107107

108108

109-
def test_export_contracts_source_not_found(tmp_path: Path) -> None:
109+
def test_cli_contracts_export_source_not_found(tmp_path: Path) -> None:
110110
"""
111111
Test assertion error when source directory not found.
112112
"""
@@ -121,7 +121,9 @@ def test_export_contracts_source_not_found(tmp_path: Path) -> None:
121121
export_contracts(output_dir=output_dir)
122122

123123

124-
def test_export_contracts_files_content(tmp_path: Path, contracts_source: Path) -> None:
124+
def test_cli_contracts_export_files_content(
125+
tmp_path: Path, contracts_source: Path
126+
) -> None:
125127
"""
126128
Test that exported files have correct content.
127129
"""
@@ -137,7 +139,7 @@ def test_export_contracts_files_content(tmp_path: Path, contracts_source: Path)
137139
assert (output_dir / "de.yaml").read_text() == "language: german\n"
138140

139141

140-
def test_export_contracts_overwrite_default_declined(
142+
def test_cli_contracts_export_overwrite_default_declined(
141143
tmp_path: Path, contracts_source: Path, capsys
142144
) -> None:
143145
"""

tests/cli/contracts/test_cli_contracts_filter.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020

2121
class TestFilterContractMetadata:
22-
def test_filter_contract_metadata_empty_file(self) -> None:
22+
def test_cli_contracts_filter_metadata_empty_file(self) -> None:
2323
"""
2424
Test filtering with an empty contract file.
2525
"""
@@ -31,7 +31,7 @@ def test_filter_contract_metadata_empty_file(self) -> None:
3131
"verbs": {"conjugations": []},
3232
}
3333

34-
def test_filter_contract_metadata_numbers_dict(self) -> None:
34+
def test_cli_contracts_filter_metadata_numbers_dict(self) -> None:
3535
"""
3636
Test filtering numbers as a dictionary.
3737
"""
@@ -48,7 +48,7 @@ def test_filter_contract_metadata_numbers_dict(self) -> None:
4848
assert "" not in result["nouns"]["numbers"]
4949
assert "collective" in result["nouns"]["numbers"]
5050

51-
def test_filter_contract_metadata_numbers_list(self) -> None:
51+
def test_cli_contracts_filter_metadata_numbers_list(self) -> None:
5252
"""
5353
Test filtering numbers as a list.
5454
"""
@@ -61,7 +61,7 @@ def test_filter_contract_metadata_numbers_list(self) -> None:
6161
result = filter_contract_metadata(Path("fake_path.json"))
6262
assert set(result["nouns"]["numbers"]) == {"singular", "plural", "dual"}
6363

64-
def test_filter_contract_metadata_numbers_string(self) -> None:
64+
def test_cli_contracts_filter_metadata_numbers_string(self) -> None:
6565
"""
6666
Test filtering numbers as a string.
6767
"""
@@ -74,7 +74,7 @@ def test_filter_contract_metadata_numbers_string(self) -> None:
7474
result = filter_contract_metadata(Path("fake_path.json"))
7575
assert set(result["nouns"]["numbers"]) == {"singular", "plural", "dual"}
7676

77-
def test_filter_contract_metadata_genders(self) -> None:
77+
def test_cli_contracts_filter_metadata_genders(self) -> None:
7878
"""
7979
Test filtering genders.
8080
"""
@@ -93,7 +93,7 @@ def test_filter_contract_metadata_genders(self) -> None:
9393
assert "NOT_INCLUDED" not in result["nouns"]["genders"]
9494
assert "" not in result["nouns"]["genders"]
9595

96-
def test_filter_contract_metadata_conjugations_list(self) -> None:
96+
def test_cli_contracts_filter_metadata_conjugations_list(self) -> None:
9797
"""
9898
Test filtering conjugations as a list.
9999
"""
@@ -107,7 +107,7 @@ def test_filter_contract_metadata_conjugations_list(self) -> None:
107107
assert set(result["verbs"]["conjugations"]) == {"run", "runs", "ran"}
108108
assert "[running]" not in result["verbs"]["conjugations"]
109109

110-
def test_filter_contract_metadata_error_handling(self) -> None:
110+
def test_cli_contracts_filter_metadata_error_handling(self) -> None:
111111
"""
112112
Test error handling for invalid YAML.
113113
"""
@@ -119,7 +119,7 @@ def test_filter_contract_metadata_error_handling(self) -> None:
119119

120120

121121
class TestFilterExportedData:
122-
def test_filter_exported_data_nouns(self) -> None:
122+
def test_cli_contracts_filter_exported_data_nouns(self) -> None:
123123
"""
124124
Test filtering exported noun data.
125125
"""
@@ -169,7 +169,7 @@ def test_filter_exported_data_nouns(self) -> None:
169169
assert result["L2"]["singular"] == "dog"
170170
assert "irrelevant" not in result["L2"]
171171

172-
def test_filter_exported_data_verbs(self) -> None:
172+
def test_cli_contracts_filter_exported_data_verbs(self) -> None:
173173
"""
174174
Test filtering exported verb data.
175175
"""
@@ -211,7 +211,7 @@ def test_filter_exported_data_verbs(self) -> None:
211211
# L4 should not be included as it doesn't have enough valid fields.
212212
assert "L4" not in result
213213

214-
def test_filter_exported_data_unsupported_type(self) -> None:
214+
def test_cli_contracts_filter_exported_data_unsupported_type(self) -> None:
215215
"""
216216
Test filtering with unsupported data type.
217217
"""
@@ -226,7 +226,7 @@ def test_filter_exported_data_unsupported_type(self) -> None:
226226
)
227227
assert result == {}
228228

229-
def test_filter_exported_data_error_handling(self) -> None:
229+
def test_cli_contracts_filter_exported_data_error_handling(self) -> None:
230230
"""
231231
Test error handling for invalid JSON.
232232
"""
@@ -253,7 +253,7 @@ class TestExportContracts:
253253
@patch("pathlib.Path.exists")
254254
@patch("builtins.open", new_callable=mock_open)
255255
@patch("json.dump")
256-
def test_export_data_filtered_by_contracts(
256+
def test_cli_contracts_export_data_filtered(
257257
self,
258258
mock_json_dump: MagicMock,
259259
mock_file_open: MagicMock,
@@ -361,7 +361,7 @@ def mock_path_glob(self: Path, pattern: str) -> list[Path]:
361361
@patch("scribe_data.cli.contracts.filter.get_language_from_iso")
362362
@patch("os.listdir")
363363
@patch("pathlib.Path.mkdir")
364-
def test_export_data_filtered_by_contracts_no_language_match(
364+
def test_cli_contracts_export_data_filtered_no_language_match(
365365
self,
366366
mock_mkdir: MagicMock,
367367
mock_listdir: MagicMock,
@@ -394,7 +394,7 @@ def test_export_data_filtered_by_contracts_no_language_match(
394394
@patch("os.listdir")
395395
@patch("pathlib.Path.mkdir")
396396
@patch("pathlib.Path.exists")
397-
def test_export_data_filtered_by_contracts_no_input_file(
397+
def test_cli_contracts_export_data_filtered_no_input_file(
398398
self,
399399
mock_exists: MagicMock,
400400
mock_mkdir: MagicMock,
@@ -428,7 +428,7 @@ def test_export_data_filtered_by_contracts_no_input_file(
428428
@patch("scribe_data.cli.contracts.filter.get_language_from_iso")
429429
@patch("os.listdir")
430430
@patch("pathlib.Path.mkdir")
431-
def test_export_data_filtered_by_contracts_empty_metadata(
431+
def test_cli_contracts_export_data_filtered_empty_metadata(
432432
self,
433433
mock_mkdir: MagicMock,
434434
mock_listdir: MagicMock,

tests/cli/convert/test_cli_convert_to_csv_or_tsv.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class TestCLIConvertToCSVorTSV(unittest.TestCase):
1717
def _setup_fixtures(self, tmp_path):
1818
self.tmp_path = tmp_path
1919

20-
def test_convert_to_csv_or_json_empty_language(self) -> None:
20+
def test_cli_convert_to_csv_or_json_empty_language(self) -> None:
2121
json_data = '{"key1": "value1", "key2": "value2"}'
2222

2323
input_file = self.tmp_path / "test.json"
@@ -37,7 +37,7 @@ def test_convert_to_csv_or_json_empty_language(self) -> None:
3737

3838
self.assertEqual(str(context.exception), "Language '' is not recognized.")
3939

40-
def test_convert_to_csv_or_tsv_standard_dict_to_csv(self) -> None:
40+
def test_cli_convert_to_csv_or_tsv_standard_dict_to_csv(self) -> None:
4141
json_data = '{"a": "1", "b": "2"}'
4242
expected_csv_output = "preposition,value\na,1\nb,2\n"
4343

@@ -59,7 +59,7 @@ def test_convert_to_csv_or_tsv_standard_dict_to_csv(self) -> None:
5959
actual_content = output_file.read_text(encoding="utf-8")
6060
assert actual_content == expected_csv_output
6161

62-
def test_convert_to_csv_or_tsv_standard_dict_to_tsv(self) -> None:
62+
def test_cli_convert_to_csv_or_tsv_standard_dict_to_tsv(self) -> None:
6363
json_data = '{"a": "1", "b": "2"}'
6464
expected_tsv_output = "preposition\tvalue\na\t1\nb\t2\n"
6565

@@ -81,7 +81,7 @@ def test_convert_to_csv_or_tsv_standard_dict_to_tsv(self) -> None:
8181
actual_content = output_file.read_text(encoding="utf-8")
8282
assert actual_content == expected_tsv_output
8383

84-
def test_convert_to_csv_or_tsv_nested_dict_to_csv(self) -> None:
84+
def test_cli_convert_to_csv_or_tsv_nested_dict_to_csv(self) -> None:
8585
json_data = (
8686
'{"a": {"value1": "1", "value2": "x"}, "b": {"value1": "2", "value2": "y"}}'
8787
)
@@ -105,7 +105,7 @@ def test_convert_to_csv_or_tsv_nested_dict_to_csv(self) -> None:
105105
actual_content = output_file.read_text(encoding="utf-8")
106106
assert actual_content == expected_csv_output
107107

108-
def test_convert_to_csv_or_tsv_nested_dict_to_tsv(self) -> None:
108+
def test_cli_convert_to_csv_or_tsv_nested_dict_to_tsv(self) -> None:
109109
json_data = (
110110
'{"a": {"value1": "1", "value2": "x"}, "b": {"value1": "2", "value2": "y"}}'
111111
)
@@ -129,7 +129,7 @@ def test_convert_to_csv_or_tsv_nested_dict_to_tsv(self) -> None:
129129
actual_content = output_file.read_text(encoding="utf-8")
130130
assert actual_content == expected_tsv_output
131131

132-
def test_convert_to_csv_or_tsv_list_of_dicts_to_csv(self) -> None:
132+
def test_cli_convert_to_csv_or_tsv_list_of_dicts_to_csv(self) -> None:
133133
json_data = '{"a": [{"emoji": "😀", "is_base": true, "rank": 1}, {"emoji": "😅", "is_base": false, "rank": 2}]}'
134134
expected_csv_output = "word,emoji,is_base,rank\na,😀,True,1\na,😅,False,2\n"
135135

@@ -151,7 +151,7 @@ def test_convert_to_csv_or_tsv_list_of_dicts_to_csv(self) -> None:
151151
actual_content = output_file.read_text(encoding="utf-8")
152152
assert actual_content == expected_csv_output
153153

154-
def test_convert_to_csv_or_tsv_list_of_dicts_to_tsv(self) -> None:
154+
def test_cli_convert_to_csv_or_tsv_list_of_dicts_to_tsv(self) -> None:
155155
json_data = '{"a": [{"emoji": "😀", "is_base": true, "rank": 1}, {"emoji": "😅", "is_base": false, "rank": 2}]}'
156156
expected_tsv_output = (
157157
"word\temoji\tis_base\trank\na\t😀\tTrue\t1\na\t😅\tFalse\t2\n"

tests/cli/convert/test_cli_convert_to_json.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class TestCLIConvertToJSON(unittest.TestCase):
2121
def _setup_fixtures(self, tmp_path):
2222
self.tmp_path = tmp_path
2323

24-
@patch("scribe_data.cli.convert.Path", autospec=True)
25-
def test_convert_to_json_empty_language(self, mock_path: MagicMock) -> None:
24+
@patch("scribe_data.cli.convert.to_json.Path", autospec=True)
25+
def test_cli_convert_to_json_empty_language(self, mock_path: MagicMock) -> None:
2626
csv_data = "key,value\na,1\nb,2"
2727
mock_file = StringIO(csv_data)
2828

@@ -43,8 +43,8 @@ def test_convert_to_json_empty_language(self, mock_path: MagicMock) -> None:
4343
)
4444
self.assertIn("Language '' is not recognized.", str(context.exception))
4545

46-
@patch("scribe_data.cli.convert.Path", autospec=True)
47-
def test_convert_to_json_supported_file_extension_csv(
46+
@patch("scribe_data.cli.convert.to_json.Path", autospec=True)
47+
def test_cli_convert_to_json_supported_file_extension_csv(
4848
self, mock_path_class: MagicMock
4949
) -> None:
5050
mock_path_instance = MagicMock(spec=Path)
@@ -63,8 +63,8 @@ def test_convert_to_json_supported_file_extension_csv(
6363
overwrite=True,
6464
)
6565

66-
@patch("scribe_data.cli.convert.Path", autospec=True)
67-
def test_convert_to_json_supported_file_extension_tsv(
66+
@patch("scribe_data.cli.convert.to_json.Path", autospec=True)
67+
def test_cli_convert_to_json_supported_file_extension_tsv(
6868
self, mock_path_class: MagicMock
6969
) -> None:
7070
mock_path_instance = MagicMock(spec=Path)
@@ -83,7 +83,7 @@ def test_convert_to_json_supported_file_extension_tsv(
8383
overwrite=True,
8484
)
8585

86-
def test_convert_to_json_unsupported_file_extension(self) -> None:
86+
def test_cli_convert_to_json_unsupported_file_extension(self) -> None:
8787
input_file = self.tmp_path / "test.txt"
8888
input_file.write_text("Hello, world!", encoding="utf-8")
8989
output_dir = self.tmp_path / "output"
@@ -105,7 +105,7 @@ def test_convert_to_json_unsupported_file_extension(self) -> None:
105105
f"Unsupported file extension '.txt' for {input_file}. Please provide a '.csv' or '.tsv' file.",
106106
)
107107

108-
def test_convert_to_json_standard_csv(self) -> None:
108+
def test_cli_convert_to_json_standard_csv(self) -> None:
109109
csv_data = "key,value\na,1\nb,2"
110110
expected_json_output = {"a": "1", "b": "2"}
111111

@@ -129,7 +129,7 @@ def test_convert_to_json_standard_csv(self) -> None:
129129

130130
assert actual_content == expected_json_output
131131

132-
def test_convert_to_json_with_multiple_keys(self) -> None:
132+
def test_cli_convert_to_json_with_multiple_keys(self) -> None:
133133
csv_data = "key,value1,value2\na,1,x\nb,2,y\nc,3,z"
134134
expected_json_output = {
135135
"a": {"value1": "1", "value2": "x"},
@@ -157,7 +157,7 @@ def test_convert_to_json_with_multiple_keys(self) -> None:
157157

158158
assert actual_content == expected_json_output
159159

160-
def test_convert_to_json_with_complex_structure(self) -> None:
160+
def test_cli_convert_to_json_with_complex_structure(self) -> None:
161161
csv_data = "key,emoji,is_base,rank\na,😀,true,1\nb,😅,false,2"
162162
expected_json_output = {
163163
"a": [{"emoji": "😀", "is_base": True, "rank": 1}],

0 commit comments

Comments
 (0)