Skip to content

Refactor systests to use pytest fixtures #475

@tseaver

Description

@tseaver

The GCS systests predate widespread adoption of pytest idioms within the organization.

Steps:

  • Add conftest.py.
  • Replace Config.CLIENT with a session-scoped client fixture.
  • Replace Config.TEST_BUCKET with a session-scoped bucket fixture.
  • Replace Config.TESTING_MTLS with a session-scoped testing_mtls fixture.
  • Replace TestClient.setupClass with a fixture which requires service account creds.
  • Replace TestClient.setUp and TestClient.tearDown with a class-scope fixture which deletes created HMAC key metadata instances.
  • Replace TestClient._get_before_hmac_keys (pre-scrubs old HMAC key metadata to avoid quota issues) with a function-scope fixture.
  • Replace TestStorageBuckets.setUp and TestStorageBuckets.tearDown with a functon-scope fixture which deletes created buckets.
  • Replace TestStorageFiles.setUpClass with a class-scope fixture which populates file metadata from cls.FILES.
  • Replace TestStorageFiles.setUp and TestStorageFiles.tearDown with a function-scope fixture which deletes created blobs.
  • Replace TestStorageWriteFiles.setUpClass with the fixture (defined above) requiring service account credentials.
  • Replace TestStorageListFiles.setUpClass / TestStorageListFiles.tearDownClass with a class-scoped fixture which scrubs, populates, and scrubs the bucket.
  • Replace TestStoragePseudoHierarchy.setUpClass / TestStoragePseudoHierarchy.tearDownClass with a class-scoped fixture which scrubs, populates, and scrubs the bucket.
  • Replace TestStorageSignURLs.setupClass with the fixuture (defined above) requiring service account credentials, plus another (replacing also tearDownClass) which creates, populates, empties, and deletes a bucket.
  • Replace TestStorageNotificationCRUD.setUpClass with the fixture (defined above) which skips the tests if testing_mtls (defined above) is true.
  • Replace TestStorageNotificationCRUD.setUp / TestStorageNotificationCRUD.tearDown with a function-scope fixture creating a bucket, adding notification to it, and then tearing both down.
  • Replace TestKMSIntegration.setUpClass with a fixture skipping under mTLS, plus scrubbing bucket.
  • Replace TestKMSIntegration.setUp (no tearDown???) with a fixture populating the keyring.
  • Replace TestRetentionPolicy.setUp / TestRetentionPolicy.tearDown with a function-scope fixture resetting / deleting created blobs, and deleting any created buckets.
  • Replace TestIAMConfiguration.setUp / TestIAMConfiguration.tearDown with a function-scope fixture deleting any created buckets.
  • Replace TestV4POSTPolicies.setUpClass with fixture (defined above) requiring service account creds.
  • Replace TestV4POSTPolicies.setUp / TestV4POSTPolicies.tearDown with a function-scope fixture deleting any created buckets.
  • Break tests/system/test_system.py into modules based on entities tested.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/python-storage API.type: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions