Skip to content

Commit 5ca6340

Browse files
authored
refactor: remove encryption_config property from Backup (#283)
* refactor: remove encryption_config property from Backup * test: only assert encryption type * test: remove references to encryption_config property Co-authored-by: larkee <[email protected]>
1 parent e990ff7 commit 5ca6340

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

google/cloud/spanner_v1/backup.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ def encryption_info(self):
185185
"""
186186
return self._encryption_info
187187

188-
@property
189-
def encryption_config(self):
190-
"""Encryption config for this database.
191-
:rtype: :class:`~google.cloud.spanner_admin_instance_v1.types.CreateBackupEncryptionConfig`
192-
:returns: an object representing the encryption config for this database
193-
"""
194-
return self._encryption_config
195-
196188
@classmethod
197189
def from_pb(cls, backup_pb, instance):
198190
"""Create an instance of this class from a protobuf message.
@@ -245,9 +237,9 @@ def create(self):
245237
if not self._database:
246238
raise ValueError("database not set")
247239
if (
248-
self.encryption_config
249-
and self.encryption_config.kms_key_name
250-
and self.encryption_config.encryption_type
240+
self._encryption_config
241+
and self._encryption_config.kms_key_name
242+
and self._encryption_config.encryption_type
251243
!= CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION
252244
):
253245
raise ValueError("kms_key_name only used with CUSTOMER_MANAGED_ENCRYPTION")

tests/system/test_system.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,7 @@ def test_backup_workflow(self):
741741
from google.cloud.spanner_admin_database_v1 import (
742742
CreateBackupEncryptionConfig,
743743
EncryptionConfig,
744+
EncryptionInfo,
744745
RestoreDatabaseEncryptionConfig,
745746
)
746747
from datetime import datetime
@@ -780,7 +781,10 @@ def test_backup_workflow(self):
780781
self.assertEqual(self.database_version_time, backup.version_time)
781782
self.assertIsNotNone(backup.size_bytes)
782783
self.assertIsNotNone(backup.state)
783-
self.assertEqual(encryption_config, backup.encryption_config)
784+
self.assertEqual(
785+
EncryptionInfo.Type.GOOGLE_DEFAULT_ENCRYPTION,
786+
backup.encryption_info.encryption_type,
787+
)
784788

785789
# Update with valid argument.
786790
valid_expire_time = datetime.utcnow() + timedelta(days=7)

tests/unit/test_backup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def test_ctor_non_defaults(self):
8484
self.assertEqual(backup._database, self.DATABASE_NAME)
8585
self.assertIsNotNone(backup._expire_time)
8686
self.assertIs(backup._expire_time, timestamp)
87-
self.assertEqual(backup.encryption_config, encryption_config)
87+
self.assertEqual(backup._encryption_config, encryption_config)
8888

8989
def test_ctor_w_encryption_config_dict(self):
9090
from google.cloud.spanner_admin_database_v1 import CreateBackupEncryptionConfig
@@ -107,7 +107,7 @@ def test_ctor_w_encryption_config_dict(self):
107107
self.assertEqual(backup._database, self.DATABASE_NAME)
108108
self.assertIsNotNone(backup._expire_time)
109109
self.assertIs(backup._expire_time, timestamp)
110-
self.assertEqual(backup.encryption_config, expected_encryption_config)
110+
self.assertEqual(backup._encryption_config, expected_encryption_config)
111111

112112
def test_from_pb_project_mismatch(self):
113113
from google.cloud.spanner_admin_database_v1 import Backup
@@ -223,7 +223,7 @@ def test_encryption_config_property(self):
223223
encryption_type=CreateBackupEncryptionConfig.EncryptionType.CUSTOMER_MANAGED_ENCRYPTION,
224224
kms_key_name="kms_key_name",
225225
)
226-
self.assertEqual(backup.encryption_config, expected)
226+
self.assertEqual(backup._encryption_config, expected)
227227

228228
def test_create_grpc_error(self):
229229
from google.api_core.exceptions import GoogleAPICallError

0 commit comments

Comments
 (0)