diff options
Diffstat (limited to 'catapult/common/py_utils/py_utils/cloud_storage_unittest.py')
-rw-r--r-- | catapult/common/py_utils/py_utils/cloud_storage_unittest.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/catapult/common/py_utils/py_utils/cloud_storage_unittest.py b/catapult/common/py_utils/py_utils/cloud_storage_unittest.py index 7648db6b..2e663a76 100644 --- a/catapult/common/py_utils/py_utils/cloud_storage_unittest.py +++ b/catapult/common/py_utils/py_utils/cloud_storage_unittest.py @@ -102,6 +102,22 @@ class CloudStorageFakeFsUnitTest(BaseFakeFsUnitTest): finally: cloud_storage._RunCommand = orig_run_command + def testUploadCreatesValidCloudUrls(self): + orig_run_command = cloud_storage._RunCommand + try: + cloud_storage._RunCommand = self._FakeRunCommand + remote_path = 'test-remote-path.html' + local_path = 'test-local-path.html' + cloud_filepath = cloud_storage.Upload( + cloud_storage.PUBLIC_BUCKET, remote_path, local_path) + self.assertEqual('https://console.developers.google.com/m/cloudstorage' + '/b/chromium-telemetry/o/test-remote-path.html', + cloud_filepath.view_url) + self.assertEqual('gs://chromium-telemetry/test-remote-path.html', + cloud_filepath.fetch_url) + finally: + cloud_storage._RunCommand = orig_run_command + @mock.patch('py_utils.cloud_storage.subprocess') def testExistsReturnsFalse(self, subprocess_mock): p_mock = mock.Mock() @@ -154,6 +170,17 @@ class CloudStorageFakeFsUnitTest(BaseFakeFsUnitTest): finally: cloud_storage._RunCommand = orig_run_command + @mock.patch('py_utils.cloud_storage._RunCommand') + def testListDirs(self, mock_run_command): + mock_run_command.return_value = '\n'.join(['gs://bucket/foo-file.txt', + '', + 'gs://bucket/foo1/', + 'gs://bucket/foo2/', + 'gs://bucket/foo1/file.txt']) + + self.assertEqual(cloud_storage.ListDirs('bucket', 'foo*'), + ['/foo1/', '/foo2/']) + @mock.patch('py_utils.cloud_storage.subprocess.Popen') def testSwarmingUsesExistingEnv(self, mock_popen): os.environ['SWARMING_HEADLESS'] = '1' |