|
| 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