|
1 | 1 | from unittest import TestCase |
2 | 2 | from ddsc.sdk.client import Client, DDSConnection, BaseResponseItem, Project, Folder, File, FileDownload, FileUpload, \ |
3 | | - ChildFinder, PathToFiles, ItemNotFound, ProjectSummary |
| 3 | + ChildFinder, PathToFiles, ItemNotFound, ProjectSummary, REMOTE_PATH_SEP |
4 | 4 | from ddsc.core.util import KindType |
5 | 5 | from mock import patch, Mock, call |
6 | 6 |
|
@@ -768,6 +768,24 @@ def test_child_not_found(self): |
768 | 768 | with self.assertRaises(ItemNotFound): |
769 | 769 | child_finder.get_child() |
770 | 770 |
|
| 771 | + def test_try_get_item_for_path_with_slash(self): |
| 772 | + node = Mock() |
| 773 | + result = ChildFinder.try_get_item_for_path(node, REMOTE_PATH_SEP) |
| 774 | + self.assertEqual(result, node) |
| 775 | + |
| 776 | + @patch('ddsc.sdk.client.ChildFinder.get_child_for_path') |
| 777 | + def test_try_get_item_for_path_with_child_found(self, mock_get_child_for_path): |
| 778 | + node = Mock() |
| 779 | + result = ChildFinder.try_get_item_for_path(node, '/file.txt') |
| 780 | + self.assertEqual(result, mock_get_child_for_path.return_value) |
| 781 | + |
| 782 | + @patch('ddsc.sdk.client.ChildFinder.get_child_for_path') |
| 783 | + def test_try_get_item_for_path_with_child_found(self, mock_get_child_for_path): |
| 784 | + mock_get_child_for_path.side_effect = ItemNotFound() |
| 785 | + node = Mock() |
| 786 | + result = ChildFinder.try_get_item_for_path(node, '/file.txt') |
| 787 | + self.assertEqual(result, None) |
| 788 | + |
771 | 789 |
|
772 | 790 | class TestPathToFiles(TestCase): |
773 | 791 | def test_path_creation(self): |
|
0 commit comments