def test_basic_multi_tenant_cm_init(self):
     store = self.prepare_store(multi_tenant=True)
     manager = connection_manager.MultiTenantConnectionManager(
         store=store, store_location=self.location, context=self.context)
     store._get_endpoint.assert_called_once_with(self.context)
     store.get_store_connection.assert_called_once_with(
         self.context.auth_token, manager.storage_url)
Exemple #2
0
 def test_multi_tenant_client_cm_with_client_creation_fails(self):
     store = self.prepare_store(multi_tenant=True)
     store.init_client.side_effect = [Exception]
     manager = connection_manager.MultiTenantConnectionManager(
         store=store,
         store_location=self.location,
         context=self.context,
         allow_reauth=True)
     store.init_client.assert_called_once_with(self.location, self.context)
     store.get_store_connection.assert_called_once_with(
         self.context.auth_token, manager.storage_url)
     self.assertFalse(manager.allow_reauth)
Exemple #3
0
 def test_multi_tenant_client_cm_with_expiration(self):
     store = self.prepare_store(multi_tenant=True)
     manager = connection_manager.MultiTenantConnectionManager(
         store=store,
         store_location=self.location,
         context=self.context,
         allow_reauth=True)
     store.init_client.assert_called_once_with(self.location, self.context)
     # return the same connection because it should not be expired
     auth_ref = mock.MagicMock()
     self.client.session.auth.get_auth_ref.return_value = auth_ref
     auth_ref.will_expire_soon.return_value = True
     manager.get_connection()
     # check that we don't update connection
     self.assertEqual(2, store.get_store_connection.call_count)
     self.assertEqual(2, self.client.session.get_auth_headers.call_count)