1717
1818@mark .fixed
1919class TestClient (MarqoTestCase ):
20+ def setUp (self ) -> None :
21+ super ().setUp ()
22+ self .initial_marqo_cloud_url = os .environ .get ("MARQO_CLOUD_URL" , constants .CLOUD_AWS_API_ENDPOINT )
23+
24+ def tearDown (self ) -> None :
25+ super ().tearDown ()
26+ os .environ ["MARQO_CLOUD_URL" ] = self .initial_marqo_cloud_url
27+
2028 def test_check_index_health_response (self ):
2129 for cloud_test_index_to_use , open_source_test_index_name in self .test_cases :
2230 test_index_name = self .get_test_index_name (
@@ -39,17 +47,16 @@ def test_check_index_health_query(self):
3947 self .assertIn (f"health" , kwargs ["path" ])
4048
4149 def test_overwrite_cloud_url_and_client_is_set_to_marqo (self ):
42- current = os .environ .get ("MARQO_CLOUD_URL" , constants .CLOUD_AWS_API_ENDPOINT )
4350 os .environ ["MARQO_CLOUD_URL" ] = "https://cloud.url.com"
4451 client = Client (url = "https://cloud.url.com" , api_key = "test" )
4552 self .assertTrue (client .config .is_marqo_cloud )
46- os .environ ["MARQO_CLOUD_URL" ] = current
4753
4854 def test_default_cloud_endpoint_client_is_marqo_cloud (self ):
4955 """
50- Checks that if a client is created with one of the 2 cloud URLs (AWS or GCP),
56+ Checks that if MARQO_CLOUD_URL is not set and a client is created with one of the 2 cloud URLs (AWS or GCP),
5157 the client is set to Marqo Cloud.
5258 """
59+ del os .environ ["MARQO_CLOUD_URL" ]
5360 for cloud_url in constants .CLOUD_API_ENDPOINTS :
5461 client = Client (url = cloud_url )
5562 self .assertTrue (client .config .is_marqo_cloud )
@@ -58,8 +65,10 @@ def test_default_cloud_endpoint_client_is_marqo_cloud(self):
5865
5966 def test_non_cloud_endpoint_client_is_not_marqo_cloud (self ):
6067 """
61- Checks that if a client is created with a non-cloud URL, the client is not set to Marqo Cloud.
68+ Checks that if MARQO_CLOUD_URL is not set and a client is created with a non-cloud URL,
69+ the client is not set to Marqo Cloud.
6270 """
71+ del os .environ ["MARQO_CLOUD_URL" ]
6372 client = Client (url = "https://arandomsite.ai" )
6473 self .assertFalse (client .config .is_marqo_cloud )
6574 self .assertIsInstance (client .config .instance_mapping , DefaultInstanceMappings )
@@ -69,9 +78,11 @@ def test_non_cloud_endpoint_client_is_not_marqo_cloud(self):
6978@mark .fixed
7079class TestClientMethods (MarqoTestCase ):
7180 def setUp (self ) -> None :
81+ super ().setUp ()
7282 self .initial_marqo_cloud_url = os .environ .get ("MARQO_CLOUD_URL" , constants .CLOUD_AWS_API_ENDPOINT )
7383
7484 def tearDown (self ) -> None :
85+ super ().tearDown ()
7586 os .environ ["MARQO_CLOUD_URL" ] = self .initial_marqo_cloud_url
7687
7788 def test_is_cloud_api_endpoint (self ):
0 commit comments