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']}
     }
Exemple #6
0
 def __radd__(self, other: Any) -> '_Increment':
     return Path(self).__radd__(other)
Exemple #7
0
 def contains(self, item):
     return Path(self).contains(item)
Exemple #8
0
 def append(self, other):
     return Path(self).append(other)
Exemple #9
0
 def delete(self, *values: Any) -> 'DeleteAction':
     return Path(self).delete(*values)
 def __le__(self, other: Any) -> 'Comparison':
     return Path(self).__le__(other)
Exemple #11
0
 def prepend(self, other: Any) -> '_ListAppend':
     return Path(self).prepend(other)
Exemple #12
0
 def remove(self) -> 'RemoveAction':
     return Path(self).remove()
Exemple #13
0
 def __getitem__(self, item: Union[int, str]) -> Path:
     return Path(self).__getitem__(item)
Exemple #14
0
 def between(self, lower: Any, upper: Any) -> 'Between':
     return Path(self).between(lower, upper)
Exemple #15
0
 def add(self, *values):
     return Path(self).add(*values)
Exemple #16
0
 def delete(self, *values):
     return Path(self).delete(*values)
Exemple #17
0
 def remove(self):
     return Path(self).remove()
Exemple #18
0
 def set(self, value):
     return Path(self).set(value)
Exemple #19
0
 def prepend(self, other):
     return Path(self).prepend(other)
Exemple #20
0
 def __rsub__(self, other: Any) -> '_Decrement':
     return Path(self).__rsub__(other)
Exemple #21
0
 def is_in(self, *values: Any) -> 'In':
     return Path(self).is_in(*values)
Exemple #22
0
 def __or__(self, other: Any) -> '_IfNotExists':
     return Path(self).__or__(other)
Exemple #23
0
 def exists(self) -> 'Exists':
     return Path(self).exists()
Exemple #24
0
 def set(self, value: Any) -> 'SetAction':
     return Path(self).set(value)
Exemple #25
0
 def __rsub__(self, other):
     return Path(self).__rsub__(other)
Exemple #26
0
 def add(self, *values: Any) -> 'AddAction':
     return Path(self).add(*values)
Exemple #27
0
 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)
Exemple #29
0
 def startswith(self, prefix: str) -> 'BeginsWith':
     return Path(self).startswith(prefix)
Exemple #30
0
 def __radd__(self, other):
     return Path(self).__radd__(other)
Exemple #31
0
 def contains(self, item: Any) -> 'Contains':
     return Path(self).contains(item)
Exemple #32
0
 def does_not_exist(self) -> 'NotExists':
     return Path(self).does_not_exist()
Exemple #33
0
 def __or__(self, other):
     return Path(self).__or__(other)
Exemple #34
0
 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)
Exemple #35
0
 def does_not_exist(self):
     return Path(self).does_not_exist()