|
| 1 | +"""Unit tests for OrganizationResource delete method. |
| 2 | +
|
| 3 | +These tests verify that the delete() method correctly builds and passes requests |
| 4 | +to the underlying API client without making real API calls. |
| 5 | +""" |
| 6 | + |
| 7 | +import pytest |
| 8 | + |
| 9 | +from pinecone.admin.resources.organization import OrganizationResource |
| 10 | +from pinecone.openapi_support import ApiClient |
| 11 | + |
| 12 | + |
| 13 | +class TestOrganizationResourceDelete: |
| 14 | + """Test parameter translation in OrganizationResource.delete()""" |
| 15 | + |
| 16 | + def setup_method(self): |
| 17 | + """Set up test fixtures""" |
| 18 | + api_client = ApiClient() |
| 19 | + self.organization_resource = OrganizationResource(api_client=api_client) |
| 20 | + |
| 21 | + def test_delete_calls_api_with_organization_id(self, mocker): |
| 22 | + """Test delete() calls the API method with correct organization_id""" |
| 23 | + mocker.patch.object( |
| 24 | + self.organization_resource._organizations_api, "delete_organization", autospec=True |
| 25 | + ) |
| 26 | + |
| 27 | + organization_id = "test-org-id-123" |
| 28 | + self.organization_resource.delete(organization_id=organization_id) |
| 29 | + |
| 30 | + # Verify API was called with correct arguments |
| 31 | + self.organization_resource._organizations_api.delete_organization.assert_called_once_with( |
| 32 | + organization_id=organization_id |
| 33 | + ) |
| 34 | + |
| 35 | + def test_delete_requires_organization_id(self): |
| 36 | + """Test that delete() requires organization_id parameter via @require_kwargs""" |
| 37 | + with pytest.raises(TypeError): |
| 38 | + self.organization_resource.delete() |
| 39 | + |
| 40 | + def test_delete_with_different_organization_id(self, mocker): |
| 41 | + """Test delete() with a different organization_id value""" |
| 42 | + mocker.patch.object( |
| 43 | + self.organization_resource._organizations_api, "delete_organization", autospec=True |
| 44 | + ) |
| 45 | + |
| 46 | + organization_id = "another-org-id-456" |
| 47 | + self.organization_resource.delete(organization_id=organization_id) |
| 48 | + |
| 49 | + # Verify API was called with the specific organization_id |
| 50 | + self.organization_resource._organizations_api.delete_organization.assert_called_once_with( |
| 51 | + organization_id=organization_id |
| 52 | + ) |
0 commit comments