Skip to content

Commit ceffe08

Browse files
committed
- Added integration test for REST Catalog namespace_exists functionality
1 parent d1e643c commit ceffe08

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import pytest
2+
3+
from pyiceberg.catalog.rest import RestCatalog
4+
5+
TEST_NAMESPACE_IDENTIFIER = "TEST NS"
6+
7+
8+
@pytest.mark.integration
9+
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog")])
10+
def test_namespace_exists(catalog: RestCatalog) -> None:
11+
if not catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER):
12+
catalog.create_namespace(TEST_NAMESPACE_IDENTIFIER)
13+
14+
assert catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER)
15+
16+
17+
@pytest.mark.integration
18+
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog")])
19+
def test_namespace_not_exists(catalog: RestCatalog) -> None:
20+
if catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER):
21+
catalog.drop_namespace(TEST_NAMESPACE_IDENTIFIER)
22+
23+
assert not catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER)
24+
25+
26+
@pytest.mark.integration
27+
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog")])
28+
def test_create_namespace_if_not_exists(catalog: RestCatalog) -> None:
29+
if catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER):
30+
catalog.drop_namespace(TEST_NAMESPACE_IDENTIFIER)
31+
32+
catalog.create_namespace_if_not_exists(TEST_NAMESPACE_IDENTIFIER)
33+
34+
assert catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER)
35+
36+
37+
@pytest.mark.integration
38+
@pytest.mark.parametrize("catalog", [pytest.lazy_fixture("session_catalog")])
39+
def test_create_namespace_if_already_existing(catalog: RestCatalog) -> None:
40+
if not catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER):
41+
catalog.create_namespace(TEST_NAMESPACE_IDENTIFIER)
42+
43+
catalog.create_namespace_if_not_exists(TEST_NAMESPACE_IDENTIFIER)
44+
45+
assert catalog.namespace_exists(TEST_NAMESPACE_IDENTIFIER)

0 commit comments

Comments
 (0)