Skip to content

Commit d640d6c

Browse files
committed
fix the assertion error
1 parent 6ed6266 commit d640d6c

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

Examples/runtimes/python/Migration/plaintext_to_awsdbe/src/plaintext/client/migration_step_0.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,6 @@ def migration_step_0_with_client(ddb_table_name: str, sort_read_value: int = 0):
6666
# Demonstrate we get the expected item back
6767
assert plaintext_item["partition_key"]["S"] == "PlaintextMigrationExample"
6868
assert plaintext_item["sort_key"]["N"] == str(sort_read_value)
69-
assert plaintext_item["attribute1"]["S"] == "encrypt and sign me!"
70-
assert plaintext_item["attribute2"]["S"] == "sign me!"
71-
assert plaintext_item[":attribute3"]["S"] == "ignore me!"
69+
assert "S" in plaintext_item["attribute1"] and plaintext_item["attribute1"]["S"] == "encrypt and sign me!"
70+
assert "S" in plaintext_item["attribute2"] and plaintext_item["attribute2"]["S"] == "sign me!"
71+
assert "S" in plaintext_item[":attribute3"] and plaintext_item[":attribute3"]["S"] == "ignore me!"

Examples/runtimes/python/Migration/plaintext_to_awsdbe/src/plaintext/resource/migration_step_0.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def migration_step_0_with_resource(ddb_table_name: str, sort_read_value: int = 0
8383
or item["partition_key"] == "PlaintextMigrationExample-2"
8484
)
8585
assert item["sort_key"] == sort_read_value
86-
assert item["attribute1"] == "encrypt and sign me!"
87-
assert item["attribute2"] == "sign me!"
88-
assert item[":attribute3"] == "ignore me!"
86+
assert "S" in item["attribute1"] and item["attribute1"]["S"] == "encrypt and sign me!"
87+
assert "S" in item["attribute2"] and item["attribute2"]["S"] == "sign me!"
88+
assert "S" in item[":attribute3"] and item[":attribute3"]["S"] == "ignore me!"
89+

Examples/runtimes/python/Migration/plaintext_to_awsdbe/test/plaintext/client/test_migration_step_0.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ def test_migration_step_0_with_client():
3737
kms_key_id=TEST_KMS_KEY_ID, ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=2
3838
)
3939
# When: Execute Step 0 with sort_read_value=2
40-
# Then: throws KeyError (i.e. cannot read encrypted values)
41-
# KeyError: attribute1 now has type "B" (binary) instead of "S" (string)
42-
with pytest.raises(KeyError):
40+
# Then: throws AssertionError (i.e. cannot read encrypted values)
41+
# AssertionError is raised when attributes have type "B" (binary) instead of "S" (string)
42+
with pytest.raises(AssertionError):
4343
migration_step_0.migration_step_0_with_client(ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=2)
4444

4545
# Given: Step 3 has succeeded
4646
migration_step_3.migration_step_3_with_client(
4747
kms_key_id=TEST_KMS_KEY_ID, ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=3
4848
)
4949
# When: Execute Step 0 with sort_read_value=3
50-
# Then: throws KeyError (i.e. cannot read encrypted values)
51-
# KeyError: attribute1 now has type "B" (binary) instead of "S" (string)
52-
with pytest.raises(KeyError):
50+
# Then: throws AssertionError (i.e. cannot read encrypted values)
51+
# AssertionError is raised when attributes have type "B" (binary) instead of "S" (string)
52+
with pytest.raises(AssertionError):
5353
migration_step_0.migration_step_0_with_client(ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=3)

Examples/runtimes/python/Migration/plaintext_to_awsdbe/test/plaintext/paginator/test_migration_step_0.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,17 @@ def test_migration_step_0_with_paginator():
3737
kms_key_id=TEST_KMS_KEY_ID, ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=2
3838
)
3939
# When: Execute Step 0 with sort_read_value=2
40-
# Then: throws KeyError (i.e. cannot read encrypted values)
41-
# KeyError: attribute1 now has type "B" (binary) instead of "S" (string)
42-
with pytest.raises(KeyError):
40+
# Then: throws AssertionError (i.e. cannot read encrypted values)
41+
# AssertionError is raised when attributes have type "B" (binary) instead of "S" (string)
42+
with pytest.raises(AssertionError):
4343
migration_step_0.migration_step_0_with_paginator(ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=2)
4444

4545
# Given: Step 3 has succeeded
4646
migration_step_3.migration_step_3_with_paginator(
4747
kms_key_id=TEST_KMS_KEY_ID, ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=3
4848
)
4949
# When: Execute Step 0 with sort_read_value=3
50-
# Then: throws KeyError (i.e. cannot read encrypted values)
51-
# KeyError: attribute1 now has type "B" (binary) instead of "S" (string)
52-
with pytest.raises(KeyError):
50+
# Then: throws AssertionError (i.e. cannot read encrypted values)
51+
# AssertionError is raised when attributes have type "B" (binary) instead of "S" (string)
52+
with pytest.raises(AssertionError):
5353
migration_step_0.migration_step_0_with_paginator(ddb_table_name=TEST_DDB_TABLE_NAME, sort_read_value=3)

0 commit comments

Comments
 (0)