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