Skip to content

Commit 15de814

Browse files
krivarddshemetov
andauthored
Apply suggestions from code review
Co-authored-by: Dmitry Shemetov <[email protected]>
1 parent 1d82025 commit 15de814

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

_delphi_utils_python/tests/test_archive.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ class Expecteds:
191191
EXPECTEDS.new
192192
EXPECTEDS.diffed_exports = EXPECTEDS.raw_exports + \
193193
[diff_name for diff_name in EXPECTEDS.common_diffs.values() if diff_name is not None]
194-
EXPECTEDS.filtered_exports = [f[:-5] for f in EXPECTEDS.diffed_exports if f.endswith(".diff")] + \
194+
EXPECTEDS.filtered_exports = [f.replace(".diff", "") for f in EXPECTEDS.diffed_exports if f.endswith(".diff")] + \
195195
EXPECTEDS.new
196196

197197
def _assert_frames_equal_ignore_row_order(df1, df2, index_cols: List[str] = None):
@@ -207,7 +207,7 @@ def set_up(self, tmp_path):
207207
def check_filtered_exports(self, export_dir):
208208
assert set(listdir(export_dir)) == set(EXPECTEDS.filtered_exports)
209209
for f in EXPECTEDS.filtered_exports:
210-
example = CSVS[f[:-4]]
210+
example = CSVS[f.replace(".csv", "")]
211211
_assert_frames_equal_ignore_row_order(
212212
pd.read_csv(join(export_dir, f), dtype=CSV_DTYPES),
213213
example.after if example.diff is None else example.diff,
@@ -247,11 +247,12 @@ def test_diff_and_filter_exports(self, tmp_path):
247247

248248
deleted_files, common_diffs, new_files = arch_diff.diff_exports()
249249

250-
# Check return values
250+
# Check deleted, common, diffed, and new file names match expected
251251
assert set(deleted_files) == {join(cache_dir, f) for f in EXPECTEDS.deleted}
252252
assert set(common_diffs.keys()) == {
253253
join(export_dir, csv_name) for csv_name in EXPECTEDS.common_diffs}
254254
assert set(new_files) == {join(export_dir, f) for f in EXPECTEDS.new}
255+
# Check that diffed file names are identical
255256
assert all(
256257
(common_diffs[join(export_dir, csv_name)] ==
257258
None if diff_name is None else join(export_dir, diff_name))
@@ -266,7 +267,7 @@ def test_diff_and_filter_exports(self, tmp_path):
266267
if diff_name is None: continue
267268
_assert_frames_equal_ignore_row_order(
268269
pd.read_csv(join(export_dir, diff_name), dtype=CSV_DTYPES),
269-
CSVS[key[:-4]].diff,
270+
CSVS[key.replace(".csv", "")].diff,
270271
index_cols=["geo_id"]
271272
)
272273

0 commit comments

Comments
 (0)