Skip to content

Commit 09bc99d

Browse files
committed
Performance Cluster Management
🐛 More file path issues on tests Fixing code that doesn't work as expected on Windows.
1 parent 7e649a9 commit 09bc99d

File tree

4 files changed

+34
-32
lines changed

4 files changed

+34
-32
lines changed

process_tracker/extract_tracker.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Used in the creation and editing of extract records. Used in conjunction with process tracking.
33
from datetime import datetime
44
import logging
5+
from pathlib import Path
56
from os.path import join
67

78
from sqlalchemy.orm import aliased
@@ -81,12 +82,14 @@ def __init__(
8182
"Location path was provided so building file path from it."
8283
)
8384

84-
self.full_filename = join(location_path, filename)
85+
self.full_filename = str(Path(location_path).joinpath(filename))
8586
else:
8687
self.logger.info("Location provided so building file path from it.")
8788

88-
self.full_filename = join(
89-
self.location.location_path, self.extract.extract_filename
89+
self.full_filename = str(
90+
Path(self.location.location_path).joinpath(
91+
self.extract.extract_filename
92+
)
9093
)
9194

9295
# Getting all status types in the event there are custom status types added later.

process_tracker/models/extract.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ def __repr__(self):
7373

7474
def full_filepath(self):
7575

76-
return str(
77-
Path(self.locations.location_path)
78-
.joinpath(self.extract_filename)
79-
.absolute()
80-
)
76+
return str(Path(self.locations.location_path).joinpath(self.extract_filename))
8177

8278

8379
class ExtractDependency(Base):

tests/test_extract_tracker.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Tests for validating extract_tracking
22
from datetime import datetime, timedelta
3+
from pathlib import Path
34
import unittest
45

56
from process_tracker.models.capacity import ClusterProcess
@@ -310,9 +311,11 @@ def test_extract_dependency_check_blocked(self):
310311
with self.assertRaises(Exception) as context:
311312
dependent_extract.extract_dependency_check()
312313

314+
clean_filename = str(Path("/home/test/extract_dir/Dependent File.csv"))
315+
313316
return self.assertTrue(
314-
"Extract files that extract /home/test/extract_dir/Dependent File.csv is dependent on have not been loaded,"
315-
" are being created, or are in the process of loading."
317+
"Extract files that extract %s is dependent on have not been loaded,"
318+
" are being created, or are in the process of loading." % clean_filename
316319
in str(context.exception)
317320
)
318321

tests/test_process_tracker.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_find_extracts_by_filename_custom_status(self):
165165
extract.change_extract_status("blarg")
166166

167167
expected_result = [
168-
str(Path("/home/test/extract_dir/test_extract_filename2.csv").absolute())
168+
str(Path("/home/test/extract_dir/test_extract_filename2.csv"))
169169
]
170170

171171
given_result = self.process_tracker.find_extracts_by_filename(
@@ -193,7 +193,7 @@ def test_find_extracts_by_filename_full(self):
193193
session.commit()
194194

195195
expected_result = [
196-
str(Path("/home/test/extract_dir/test_extract_filename2.csv").absolute())
196+
str(Path("/home/test/extract_dir/test_extract_filename2.csv"))
197197
]
198198

199199
given_result = self.process_tracker.find_extracts_by_filename(
@@ -233,8 +233,8 @@ def test_find_extracts_by_filename_partial(self):
233233
session.commit()
234234

235235
expected_result = [
236-
str(Path("/home/test/extract_dir/test_extract_filename3-1.csv").absolute()),
237-
str(Path("/home/test/extract_dir/test_extract_filename3-2.csv").absolute()),
236+
str(Path("/home/test/extract_dir/test_extract_filename3-1.csv")),
237+
str(Path("/home/test/extract_dir/test_extract_filename3-2.csv")),
238238
]
239239

240240
given_result = self.process_tracker.find_extracts_by_filename(
@@ -274,8 +274,8 @@ def test_find_extracts_by_filename_partial_not_descending(self):
274274
session.commit()
275275

276276
expected_result = [
277-
str(Path("/home/test/extract_dir/test_extract_filename3-2.csv").absolute()),
278-
str(Path("/home/test/extract_dir/test_extract_filename3-1.csv").absolute()),
277+
str(Path("/home/test/extract_dir/test_extract_filename3-2.csv")),
278+
str(Path("/home/test/extract_dir/test_extract_filename3-1.csv")),
279279
]
280280

281281
given_result = self.process_tracker.find_extracts_by_filename(
@@ -310,8 +310,8 @@ def test_find_extracts_by_location_name_custom_status(self):
310310
extract2.change_extract_status("blarg")
311311

312312
expected_result = [
313-
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv").absolute()),
314-
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv").absolute()),
313+
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv")),
314+
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv")),
315315
]
316316

317317
given_result = self.process_tracker.find_extracts_by_location(
@@ -351,8 +351,8 @@ def test_find_extracts_by_location_name(self):
351351
session.commit()
352352

353353
expected_result = [
354-
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv").absolute()),
355-
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv").absolute()),
354+
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv")),
355+
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv")),
356356
]
357357

358358
given_result = self.process_tracker.find_extracts_by_location(
@@ -392,8 +392,8 @@ def test_find_extracts_by_location_not_descending(self):
392392
session.commit()
393393

394394
expected_result = [
395-
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv").absolute()),
396-
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv").absolute()),
395+
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv")),
396+
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv")),
397397
]
398398

399399
given_result = self.process_tracker.find_extracts_by_location(
@@ -429,8 +429,8 @@ def test_find_extracts_by_location_path_custom_status(self):
429429
extract2.change_extract_status("blarg")
430430

431431
expected_result = [
432-
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv").absolute()),
433-
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv").absolute()),
432+
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv")),
433+
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv")),
434434
]
435435

436436
given_result = self.process_tracker.find_extracts_by_location(
@@ -470,8 +470,8 @@ def test_find_extracts_by_location_path(self):
470470
session.commit()
471471

472472
expected_result = [
473-
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv").absolute()),
474-
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv").absolute()),
473+
str(Path("/home/test/extract_dir/test_extract_filename4-1.csv")),
474+
str(Path("/home/test/extract_dir/test_extract_filename4-2.csv")),
475475
]
476476

477477
given_result = self.process_tracker.find_extracts_by_location(
@@ -520,8 +520,8 @@ def test_find_extracts_by_process_custom_status(self):
520520
extract2.change_extract_status("blarg")
521521

522522
expected_result = [
523-
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv").absolute()),
524-
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv").absolute()),
523+
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv")),
524+
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv")),
525525
]
526526

527527
given_result = self.process_tracker.find_extracts_by_process(
@@ -560,8 +560,8 @@ def test_find_extracts_by_process(self):
560560
session.commit()
561561

562562
expected_result = [
563-
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv").absolute()),
564-
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv").absolute()),
563+
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv")),
564+
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv")),
565565
]
566566

567567
given_result = self.process_tracker.find_extracts_by_process(
@@ -606,8 +606,8 @@ def test_find_extracts_by_process_not_descending(self):
606606
session.commit()
607607

608608
expected_result = [
609-
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv").absolute()),
610-
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv").absolute()),
609+
str(Path("/home/test/extract_dir/test_extract_filename5-2.csv")),
610+
str(Path("/home/test/extract_dir/test_extract_filename5-1.csv")),
611611
]
612612

613613
given_result = self.process_tracker.find_extracts_by_process(

0 commit comments

Comments
 (0)