-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from xoeye/fix/all_items_for_next_attempt-mult…
…i-schema fix: Update all_items_for_next_attempt to handle different key schemas
- Loading branch information
Showing
14 changed files
with
60 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
import xoto3.dynamodb.write_versioned as wv | ||
from xoto3.dynamodb.write_versioned.prepare import ( | ||
add_item_to_base_request, | ||
all_items_for_next_attempt, | ||
parse_batch_get_request, | ||
) | ||
|
||
|
||
def test_disallow_non_matching_keys(): | ||
with pytest.raises(AssertionError): | ||
parse_batch_get_request(dict(tbl1=[dict(id=1), dict(other_key=2)])) | ||
|
||
|
||
def test_deduplicate_keys(): | ||
req = [dict(id=1), dict(id=1), dict(id=2)] | ||
|
||
res = parse_batch_get_request(dict(tbl1=req)) | ||
assert res == dict(tbl1=[dict(id=1), dict(id=2)]) | ||
|
||
|
||
def test_add_item(): | ||
tname_onto_item_keys = add_item_to_base_request( | ||
dict(table1=[dict(id=1)]), ("table2", dict(id=3)), | ||
) | ||
|
||
assert tname_onto_item_keys == dict(table1=[dict(id=1)], table2=[dict(id=3)],) | ||
|
||
|
||
def test_all_items_for_next_attempt_different_key_schemas(): | ||
FooTable = wv.ItemTable("Foo") | ||
BarTable = wv.ItemTable("Bar") | ||
BazTable = wv.ItemTable("Baz") | ||
vt = wv.VersionedTransaction(dict()) | ||
vt = FooTable.define("someKey")(vt) | ||
vt = BarTable.define("someOtherKey")(vt) | ||
vt = BazTable.define("aThirdKey")(vt) | ||
vt = FooTable.presume(dict(someKey="foo-1"), dict(someKey="foo-1"))(vt) | ||
vt = BarTable.presume(dict(someOtherKey="bar-1"), dict(someOtherKey="bar-1"))(vt) | ||
vt = BazTable.presume(dict(aThirdKey="baz-1"), dict(aThirdKey="baz-1"))(vt) | ||
vt = BazTable.presume(dict(aThirdKey="baz-2"), dict(aThirdKey="baz-2"))(vt) | ||
|
||
result = all_items_for_next_attempt(vt) | ||
assert result["Foo"] == [dict(someKey="foo-1")] | ||
assert result["Bar"] == [dict(someOtherKey="bar-1")] | ||
assert dict(aThirdKey="baz-1") in result["Baz"] | ||
assert dict(aThirdKey="baz-2") in result["Baz"] |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
23 changes: 0 additions & 23 deletions
23
tests/xoto3/dynamodb/write_versioned/transact/prepare_test.py
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""xoto3""" | ||
__version__ = "1.12.0" | ||
__version__ = "1.12.1" | ||
__author__ = "Peter Gaultney" | ||
__author_email__ = "[email protected]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters