32
32
NoSuchNamespaceError ,
33
33
NoSuchTableError ,
34
34
OAuthError ,
35
+ ServerError ,
35
36
TableAlreadyExistsError ,
36
37
)
37
38
from pyiceberg .io import load_file_io
@@ -701,17 +702,17 @@ def test_load_table_404(rest_mock: Mocker) -> None:
701
702
assert "Table does not exist" in str (e .value )
702
703
703
704
704
- def test_table_exist_200 (rest_mock : Mocker ) -> None :
705
+ def test_table_exists_200 (rest_mock : Mocker ) -> None :
705
706
rest_mock .head (
706
707
f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
707
708
status_code = 200 ,
708
709
request_headers = TEST_HEADERS ,
709
710
)
710
711
catalog = RestCatalog ("rest" , uri = TEST_URI , token = TEST_TOKEN )
711
- assert catalog .table_exists (("fokko" , "table" ))
712
+ assert not catalog .table_exists (("fokko" , "table" ))
712
713
713
714
714
- def test_table_exist_204 (rest_mock : Mocker ) -> None :
715
+ def test_table_exists_204 (rest_mock : Mocker ) -> None :
715
716
rest_mock .head (
716
717
f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
717
718
status_code = 204 ,
@@ -721,16 +722,28 @@ def test_table_exist_204(rest_mock: Mocker) -> None:
721
722
assert catalog .table_exists (("fokko" , "table" ))
722
723
723
724
724
- def test_table_exist_500 (rest_mock : Mocker ) -> None :
725
+ def test_table_exists_404 (rest_mock : Mocker ) -> None :
725
726
rest_mock .head (
726
727
f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
727
- status_code = 500 ,
728
+ status_code = 404 ,
728
729
request_headers = TEST_HEADERS ,
729
730
)
730
731
catalog = RestCatalog ("rest" , uri = TEST_URI , token = TEST_TOKEN )
731
732
assert not catalog .table_exists (("fokko" , "table" ))
732
733
733
734
735
+ def test_table_exists_500 (rest_mock : Mocker ) -> None :
736
+ rest_mock .head (
737
+ f"{ TEST_URI } v1/namespaces/fokko/tables/table" ,
738
+ status_code = 500 ,
739
+ request_headers = TEST_HEADERS ,
740
+ )
741
+ catalog = RestCatalog ("rest" , uri = TEST_URI , token = TEST_TOKEN )
742
+
743
+ with pytest .raises (ServerError ):
744
+ catalog .table_exists (("fokko" , "table" ))
745
+
746
+
734
747
def test_drop_table_404 (rest_mock : Mocker ) -> None :
735
748
rest_mock .delete (
736
749
f"{ TEST_URI } v1/namespaces/fokko/tables/does_not_exists" ,
0 commit comments