-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HC-418: Support nominal S3 pathing style (#33)
* HC-418: Support usage of nominal S3 pathing styles * Add unit test for utility function that determines the S3 bucket and key * add newline * fixed typos, make unit test more generic * get endpoint from region_info; check for default region * try getting 169.254.169.254 to get the region * fix messaging * Bump version Co-authored-by: Mike Cayanan <michael.d.cayanan@jpl.nasa.gov>
- Loading branch information
Showing
4 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
|
||
from osaka import utils | ||
|
||
|
||
class UtilsTest(unittest.TestCase): | ||
def setUp(self): | ||
self.legacy_s3_url = "s3://s3-us-west-2.amazonaws.com:80/my_bucket/foo/bar/key" | ||
self.nominal_s3_url = "s3://my_bucket/foo/bar/key" | ||
self.expected_container = "my_bucket" | ||
self.expected_key = "foo/bar/key" | ||
|
||
def test_get_s3_container_and_path_legacy_style(self): | ||
container, key = utils.get_s3_container_and_path(self.legacy_s3_url) | ||
self.assertEquals(container, | ||
self.expected_container, | ||
f"Did not get expected container value: " | ||
f"container={container}, expected={self.expected_container}") | ||
self.assertEquals(key, self.expected_key, f"Did not get expected key value: key={key}, " | ||
f"expected={self.expected_key}") | ||
|
||
def test_get_s3_container_and_path_nominal_style(self): | ||
container, key = utils.get_s3_container_and_path(self.nominal_s3_url, is_nominal_style=True) | ||
self.assertEquals(container, self.expected_container, | ||
f"Did not get expected container value: " | ||
f"container={container}, expected={self.expected_container}") | ||
self.assertEquals(key, self.expected_key, f"Did not get expected key value: key={key}, " | ||
f"expected={self.expected_key}") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters