Skip to content

Commit 564fd7d

Browse files
authored
Merge pull request #38 from OpenDataAlex/process_tracker_python-29
Process tracker python 29
2 parents eeb54d3 + 0d47a32 commit 564fd7d

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

process_tracker/location_tracker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def derive_location_type(self):
8686
)
8787

8888
location_type = self.data_store.get_or_create_item(
89-
model=LocationType, location_type_name="local directory"
89+
model=LocationType, location_type_name="local filesystem"
9090
)
9191

9292
return location_type

tests/test_location_tracker.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import unittest
2+
3+
from process_tracker.location_tracker import LocationTracker
4+
5+
6+
class TestLocationTracker(unittest.TestCase):
7+
def test_derive_location_name_none(self):
8+
"""
9+
Testing that if no location name is provided, and it's not a location path, the last directory is set as the
10+
location name.
11+
:return:
12+
"""
13+
test_path = "/tmp/testing/test_dir"
14+
15+
expected_result = "test_dir"
16+
given_result = LocationTracker(location_path=test_path).location_name
17+
18+
self.assertEqual(expected_result, given_result)
19+
20+
def test_derive_location_name_s3(self):
21+
"""
22+
Testing that if no location name is provided, and it's an s3 location path, the s3 prefix is added.
23+
:return:
24+
"""
25+
test_path = "s3://tmp/testing/test_dir"
26+
27+
expected_result = "s3 - test_dir"
28+
given_result = LocationTracker(location_path=test_path).location_name
29+
30+
self.assertEqual(expected_result, given_result)
31+
32+
def test_derive_location_type_local(self):
33+
"""
34+
Testing that if no other location type is found, set as local filesystem.
35+
:return:
36+
"""
37+
test_path = "/tmp/testing/test_dir"
38+
39+
expected_result = "local filesystem"
40+
given_result = LocationTracker(
41+
location_path=test_path
42+
).location_type.location_type_name
43+
44+
self.assertEqual(expected_result, given_result)
45+
46+
def test_derive_location_type_s3(self):
47+
"""
48+
Testing that if s3 is part of the location path, the type is set to s3.
49+
:return:
50+
"""
51+
test_path = "s3://tmp/testing/test_dir"
52+
53+
expected_result = "s3"
54+
given_result = LocationTracker(
55+
location_path=test_path
56+
).location_type.location_type_name
57+
58+
self.assertEqual(expected_result, given_result)

0 commit comments

Comments
 (0)