|
20 | 20 |
|
21 | 21 | @patch("shutil.rmtree", Mock())
|
22 | 22 | @patch("sagemaker.local.utils.recursive_copy")
|
23 |
| -def test_move_to_destination(recursive_copy): |
| 23 | +def test_move_to_destination_local(recursive_copy): |
24 | 24 | # local files will just be recursively copied
|
25 | 25 | sagemaker.local.utils.move_to_destination("/tmp/data", "file:///target/dir/", "job", None)
|
26 | 26 | recursive_copy.assert_called_with("/tmp/data", "/target/dir/")
|
27 | 27 |
|
28 |
| - # s3 destination will upload to S3 |
| 28 | + |
| 29 | +@patch("shutil.rmtree", Mock()) |
| 30 | +@patch("sagemaker.local.utils.recursive_copy") |
| 31 | +def test_move_to_destination_s3(recursive_copy): |
29 | 32 | sms = Mock()
|
| 33 | + |
| 34 | + # without trailing slash in prefix |
30 | 35 | sagemaker.local.utils.move_to_destination("/tmp/data", "s3://bucket/path", "job", sms)
|
31 |
| - sms.upload_data.assert_called() |
| 36 | + sms.upload_data.assert_called_with("/tmp/data", "bucket", "path/job") |
| 37 | + recursive_copy.assert_not_called() |
| 38 | + |
| 39 | + # with trailing slash in prefix |
| 40 | + sagemaker.local.utils.move_to_destination("/tmp/data", "s3://bucket/path/", "job", sms) |
| 41 | + sms.upload_data.assert_called_with("/tmp/data", "bucket", "path/job") |
| 42 | + |
| 43 | + # without path, with trailing slash |
| 44 | + sagemaker.local.utils.move_to_destination("/tmp/data", "s3://bucket/", "job", sms) |
| 45 | + sms.upload_data.assert_called_with("/tmp/data", "bucket", "job") |
| 46 | + |
| 47 | + # without path, without trailing slash |
| 48 | + sagemaker.local.utils.move_to_destination("/tmp/data", "s3://bucket", "job", sms) |
| 49 | + sms.upload_data.assert_called_with("/tmp/data", "bucket", "job") |
32 | 50 |
|
33 | 51 |
|
34 | 52 | def test_move_to_destination_illegal_destination():
|
|
0 commit comments