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