Skip to content

Commit 003c0e8

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

File tree

5 files changed

+19
-19
lines changed

5 files changed

+19
-19
lines changed

.github/workflows/ci_examples_python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ jobs:
9797
# Run legacy migration examples
9898
tox -e legacymigration
9999
# Run plaintext migration examples
100-
tox -e plaintextmigration
100+
tox -e plaintextmigration

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/paginator/migration_step_0.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,6 @@ def migration_step_0_with_paginator(ddb_table_name: str, sort_read_value: int =
6868
item = next((i for i in items if i["sort_key"]["N"] == str(sort_read_value)), None)
6969
assert item is not None
7070
assert item["partition_key"]["S"] == "PlaintextMigrationExample"
71-
assert item["attribute1"]["S"] == "encrypt and sign me!"
72-
assert item["attribute2"]["S"] == "sign me!"
73-
assert item[":attribute3"]["S"] == "ignore me!"
71+
assert "S" in item["attribute1"] and item["attribute1"]["S"] == "encrypt and sign me!"
72+
assert "S" in item["attribute2"] and item["attribute2"]["S"] == "sign me!"
73+
assert "S" in item[":attribute3"] and item[":attribute3"]["S"] == "ignore me!"

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)