def test_set_action(self): action = Path('foo').set('bar') placeholder_names, expression_attribute_values = {}, {} expression = action.serialize(placeholder_names, expression_attribute_values) assert expression == "#0 = :0" assert placeholder_names == {'foo': '#0'} assert expression_attribute_values == {':0': {'S': 'bar'}}
def test_delete_action(self): action = Path('foo').difference_update({'NS': ['0']}) placeholder_names, expression_attribute_values = {}, {} expression = action.serialize(placeholder_names, expression_attribute_values) assert expression == "#0 :0" assert placeholder_names == {'foo': '#0'} assert expression_attribute_values == {':0': {'NS': ['0']}}
def test_remove_action(self): action = Path('foo').remove() placeholder_names, expression_attribute_values = {}, {} expression = action.serialize(placeholder_names, expression_attribute_values) assert expression == "#0" assert placeholder_names == {'foo': '#0'} assert expression_attribute_values == {}
def test_add_action(self): action = Path('foo').update(0) placeholder_names, expression_attribute_values = {}, {} expression = action.serialize(placeholder_names, expression_attribute_values) assert expression == "#0 :0" assert placeholder_names == {'foo': '#0'} assert expression_attribute_values == {':0': {'N': '0'}}
def test_update(self): path = Path('foo') update = Update() update.add_action(path.set({'S': 'bar'})) update.add_action(path.remove()) update.add_action(path.update({'N': '0'})) update.add_action(path.difference_update({'NS': ['0']})) placeholder_names, expression_attribute_values = {}, {} expression = update.serialize(placeholder_names, expression_attribute_values) assert expression == "SET #0 = :0 REMOVE #0 ADD #0 :1 DELETE #0 :2" assert placeholder_names == {'foo': '#0'} assert expression_attribute_values == { ':0': {'S': 'bar'}, ':1': {'N': '0'}, ':2': {'NS': ['0']} }
def __radd__(self, other: Any) -> '_Increment': return Path(self).__radd__(other)
def contains(self, item): return Path(self).contains(item)
def append(self, other): return Path(self).append(other)
def delete(self, *values: Any) -> 'DeleteAction': return Path(self).delete(*values)
def __le__(self, other: Any) -> 'Comparison': return Path(self).__le__(other)
def prepend(self, other: Any) -> '_ListAppend': return Path(self).prepend(other)
def remove(self) -> 'RemoveAction': return Path(self).remove()
def __getitem__(self, item: Union[int, str]) -> Path: return Path(self).__getitem__(item)
def between(self, lower: Any, upper: Any) -> 'Between': return Path(self).between(lower, upper)
def add(self, *values): return Path(self).add(*values)
def delete(self, *values): return Path(self).delete(*values)
def remove(self): return Path(self).remove()
def set(self, value): return Path(self).set(value)
def prepend(self, other): return Path(self).prepend(other)
def __rsub__(self, other: Any) -> '_Decrement': return Path(self).__rsub__(other)
def is_in(self, *values: Any) -> 'In': return Path(self).is_in(*values)
def __or__(self, other: Any) -> '_IfNotExists': return Path(self).__or__(other)
def exists(self) -> 'Exists': return Path(self).exists()
def set(self, value: Any) -> 'SetAction': return Path(self).set(value)
def __rsub__(self, other): return Path(self).__rsub__(other)
def add(self, *values: Any) -> 'AddAction': return Path(self).add(*values)
def startswith(self, prefix): return Path(self).startswith(prefix)
def remove_indexes(self, *indexes): if not all([isinstance(i, int) for i in indexes]): raise ValueError("Method 'remove_indexes' arguments must be 'int'") return Path(self).remove_list_elements(*indexes)
def startswith(self, prefix: str) -> 'BeginsWith': return Path(self).startswith(prefix)
def __radd__(self, other): return Path(self).__radd__(other)
def contains(self, item: Any) -> 'Contains': return Path(self).contains(item)
def does_not_exist(self) -> 'NotExists': return Path(self).does_not_exist()
def __or__(self, other): return Path(self).__or__(other)
def is_type(self): # What makes sense here? Are we using this to check if deserialization will be successful? return Path(self).is_type(self.attr_type)
def does_not_exist(self): return Path(self).does_not_exist()