-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from .dir import get_ds_path_uri | ||
from .jobs import get_status, runtime_summary, generate_job_info | ||
from .jobs import get_status, runtime_summary, generate_job_info, get_archive_path |
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,34 @@ | ||
import unittest | ||
from unittest.mock import patch, Mock | ||
from dsjobs import get_archive_path | ||
|
||
|
||
class TestGetArchivePath(unittest.TestCase): | ||
def test_get_archive_path(self): | ||
# Create a mock Agave object and its method return value | ||
mock_ag = Mock() | ||
mock_job_info = Mock() | ||
mock_job_info.archivePath = "user123/jobdata/somefile" | ||
mock_ag.jobs.get.return_value = mock_job_info | ||
|
||
# Call the function | ||
result = get_archive_path(mock_ag, "dummy_job_id") | ||
|
||
# Check the result | ||
expected_path = "/home/jupyter/MyData/jobdata/somefile" | ||
self.assertEqual(result, expected_path) | ||
|
||
def test_get_archive_path_invalid_format(self): | ||
# Create a mock Agave object with an unexpected format return | ||
mock_ag = Mock() | ||
mock_job_info = Mock() | ||
mock_job_info.archivePath = "invalid_format_path" | ||
mock_ag.jobs.get.return_value = mock_job_info | ||
|
||
# Check if the function raises a ValueError as expected | ||
with self.assertRaises(ValueError): | ||
get_archive_path(mock_ag, "dummy_job_id") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |