From f2bbc87f5f2c8f27950d7a97847a8c2ce8709faa Mon Sep 17 00:00:00 2001 From: bubriks Date: Thu, 19 Dec 2024 14:28:41 +0200 Subject: [PATCH] tests --- .../hsfs/spark/TestStorageConnector.java | 28 +++++++++++++++++++ python/tests/test_storage_connector.py | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/java/spark/src/test/java/com/logicalclocks/hsfs/spark/TestStorageConnector.java b/java/spark/src/test/java/com/logicalclocks/hsfs/spark/TestStorageConnector.java index f4bd0c591..e207484bf 100644 --- a/java/spark/src/test/java/com/logicalclocks/hsfs/spark/TestStorageConnector.java +++ b/java/spark/src/test/java/com/logicalclocks/hsfs/spark/TestStorageConnector.java @@ -19,6 +19,7 @@ import com.logicalclocks.hsfs.FeatureStoreException; import com.logicalclocks.hsfs.StorageConnectorType; +import com.logicalclocks.hsfs.StorageConnector.S3Connector; import com.logicalclocks.hsfs.metadata.HopsworksClient; import com.logicalclocks.hsfs.metadata.HopsworksHttpClient; import com.logicalclocks.hsfs.metadata.Option; @@ -245,6 +246,33 @@ void testDefaultPathS3() throws FeatureStoreException, IOException { // reset SparkEngine.setInstance(null); } + + @Test + void testGetPath() throws FeatureStoreException, IOException { + // Arrange + S3Connector connector = new S3Connector(); + connector.setBucket("testBucket"); + + // Act + String path = connector.getPath("some/location"); + + // Assert + Assertions.assertEquals("s3://testBucket/some/location", path); + } + + @Test + void testGetPathStorageConnectorWithPath() throws FeatureStoreException, IOException { + // Arrange + S3Connector connector = new S3Connector(); + connector.setBucket("testBucket"); + connector.setPath("abc/def"); + + // Act + String path = connector.getPath("some/location"); + + // Assert + Assertions.assertEquals("s3://testBucket/abc/def/some/location", path); + } } @Nested diff --git a/python/tests/test_storage_connector.py b/python/tests/test_storage_connector.py index 235db7836..5dc96a546 100644 --- a/python/tests/test_storage_connector.py +++ b/python/tests/test_storage_connector.py @@ -114,7 +114,7 @@ def test_default_path(self, mocker): sc.read(data_format="csv") # assert assert "" == mock_engine_read.call_args[0][3] - + def test_get_path(self, mocker): mocker.patch("hsfs.engine.get_instance", return_value=spark.Engine()) sc = storage_connector.S3Connector(