Skip to content

Commit

Permalink
Add test for Ceph bucket names.
Browse files Browse the repository at this point in the history
  • Loading branch information
ktlim committed Apr 18, 2023
1 parent aebfb71 commit 830c6db
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_s3utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

import os
import unittest
from unittest import mock

from lsst.resources.s3utils import clean_test_environment

try:
import boto3
from boto3.exceptions import ParamValidationError
from moto import mock_s3
except ImportError:
boto3 = None
Expand Down Expand Up @@ -82,6 +85,14 @@ def testBucketExists(self):
self.assertTrue(bucketExists(f"{self.bucketName}"))
self.assertFalse(bucketExists(f"{self.bucketName}_no_exist"))

def testCephBucket(self):
with self.assertRaises(ParamValidationError):
bucketExists("foo:bar")

@mock.patch.dict(os.environ, {"LSST_CEPH_BUCKETS", "1"})
def testCephBucketSuccess(self):
self.assertFalse("foo:bar")

def testFileExists(self):
self.assertTrue(s3CheckFileExists(client=self.client, bucket=self.bucketName, path=self.fileName)[0])
self.assertFalse(
Expand Down

0 comments on commit 830c6db

Please sign in to comment.