Skip to content

Commit c1fec05

Browse files
committed
Performance Cluster Management
🐛 Filepaths on Windows weren't right Tests were failing on Windows due to filepaths not being fully taken into account. Modified tests to accommodate.
1 parent 801d1d8 commit c1fec05

File tree

2 files changed

+33
-24
lines changed

2 files changed

+33
-24
lines changed

process_tracker/models/extract.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Models for Extract (Data) entities
33

44
from datetime import datetime
5-
from os.path import join
5+
from pathlib import Path
66

77
from sqlalchemy import Column, DateTime, ForeignKey, Integer, Sequence, String
88
from sqlalchemy.orm import relationship
@@ -73,7 +73,11 @@ def __repr__(self):
7373

7474
def full_filepath(self):
7575

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

7882

7983
class ExtractDependency(Base):

tests/test_process_tracker.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from datetime import datetime, timedelta
44
import os
5+
from pathlib import Path
56
import time
67
import unittest
78
from unittest.mock import patch
@@ -163,7 +164,9 @@ def test_find_extracts_by_filename_custom_status(self):
163164
# Need to manually change the status, because this would normally be done while the process was processing data
164165
extract.change_extract_status("blarg")
165166

166-
expected_result = ["/home/test/extract_dir/test_extract_filename2.csv"]
167+
expected_result = [
168+
str(Path("/home/test/extract_dir/test_extract_filename2.csv").absolute())
169+
]
167170

168171
given_result = self.process_tracker.find_extracts_by_filename(
169172
"test_extract_filename2.csv", status="blarg"
@@ -189,7 +192,9 @@ def test_find_extracts_by_filename_full(self):
189192
session = Session.object_session(extract.extract)
190193
session.commit()
191194

192-
expected_result = ["/home/test/extract_dir/test_extract_filename2.csv"]
195+
expected_result = [
196+
str(Path("/home/test/extract_dir/test_extract_filename2.csv").absolute())
197+
]
193198

194199
given_result = self.process_tracker.find_extracts_by_filename(
195200
"test_extract_filename2.csv"
@@ -228,8 +233,8 @@ def test_find_extracts_by_filename_partial(self):
228233
session.commit()
229234

230235
expected_result = [
231-
"/home/test/extract_dir/test_extract_filename3-1.csv",
232-
"/home/test/extract_dir/test_extract_filename3-2.csv",
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()),
233238
]
234239

235240
given_result = self.process_tracker.find_extracts_by_filename(
@@ -269,8 +274,8 @@ def test_find_extracts_by_filename_partial_not_descending(self):
269274
session.commit()
270275

271276
expected_result = [
272-
"/home/test/extract_dir/test_extract_filename3-2.csv",
273-
"/home/test/extract_dir/test_extract_filename3-1.csv",
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()),
274279
]
275280

276281
given_result = self.process_tracker.find_extracts_by_filename(
@@ -305,8 +310,8 @@ def test_find_extracts_by_location_name_custom_status(self):
305310
extract2.change_extract_status("blarg")
306311

307312
expected_result = [
308-
"/home/test/extract_dir/test_extract_filename4-1.csv",
309-
"/home/test/extract_dir/test_extract_filename4-2.csv",
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()),
310315
]
311316

312317
given_result = self.process_tracker.find_extracts_by_location(
@@ -346,8 +351,8 @@ def test_find_extracts_by_location_name(self):
346351
session.commit()
347352

348353
expected_result = [
349-
"/home/test/extract_dir/test_extract_filename4-1.csv",
350-
"/home/test/extract_dir/test_extract_filename4-2.csv",
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()),
351356
]
352357

353358
given_result = self.process_tracker.find_extracts_by_location(
@@ -387,8 +392,8 @@ def test_find_extracts_by_location_not_descending(self):
387392
session.commit()
388393

389394
expected_result = [
390-
"/home/test/extract_dir/test_extract_filename4-2.csv",
391-
"/home/test/extract_dir/test_extract_filename4-1.csv",
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()),
392397
]
393398

394399
given_result = self.process_tracker.find_extracts_by_location(
@@ -424,8 +429,8 @@ def test_find_extracts_by_location_path_custom_status(self):
424429
extract2.change_extract_status("blarg")
425430

426431
expected_result = [
427-
"/home/test/extract_dir/test_extract_filename4-1.csv",
428-
"/home/test/extract_dir/test_extract_filename4-2.csv",
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()),
429434
]
430435

431436
given_result = self.process_tracker.find_extracts_by_location(
@@ -465,8 +470,8 @@ def test_find_extracts_by_location_path(self):
465470
session.commit()
466471

467472
expected_result = [
468-
"/home/test/extract_dir/test_extract_filename4-1.csv",
469-
"/home/test/extract_dir/test_extract_filename4-2.csv",
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()),
470475
]
471476

472477
given_result = self.process_tracker.find_extracts_by_location(
@@ -515,8 +520,8 @@ def test_find_extracts_by_process_custom_status(self):
515520
extract2.change_extract_status("blarg")
516521

517522
expected_result = [
518-
"/home/test/extract_dir/test_extract_filename5-1.csv",
519-
"/home/test/extract_dir/test_extract_filename5-2.csv",
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()),
520525
]
521526

522527
given_result = self.process_tracker.find_extracts_by_process(
@@ -555,8 +560,8 @@ def test_find_extracts_by_process(self):
555560
session.commit()
556561

557562
expected_result = [
558-
"/home/test/extract_dir/test_extract_filename5-1.csv",
559-
"/home/test/extract_dir/test_extract_filename5-2.csv",
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()),
560565
]
561566

562567
given_result = self.process_tracker.find_extracts_by_process(
@@ -601,8 +606,8 @@ def test_find_extracts_by_process_not_descending(self):
601606
session.commit()
602607

603608
expected_result = [
604-
"/home/test/extract_dir/test_extract_filename5-2.csv",
605-
"/home/test/extract_dir/test_extract_filename5-1.csv",
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()),
606611
]
607612

608613
given_result = self.process_tracker.find_extracts_by_process(

0 commit comments

Comments
 (0)