Exemple #1
0
 def test_serialize(self):
     response = serialize(Remove("foo"))
     assert response == {
         "UpdateExpression": "REMOVE #ref1 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo"
         },
     }
Exemple #2
0
 def test_serialize(self):
     response = serialize(Increase("foo", 1))
     assert response == {
         "UpdateExpression": "SET #ref1 = #ref1 + :val1 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo"
         },
         "ExpressionAttributeValues": {
             ":val1": 1
         },
     }
Exemple #3
0
 def test_serialize(self):
     response = serialize(Set("foo", "bar"))
     assert response == {
         "UpdateExpression": "SET #ref1 = :val1 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo"
         },
         "ExpressionAttributeValues": {
             ":val1": "bar"
         },
     }
Exemple #4
0
 def test_serialize(self):
     response = serialize(Delete("foo", 1))
     assert response == {
         "UpdateExpression": "DELETE #ref1 :val1 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo"
         },
         "ExpressionAttributeValues": {
             ":val1": 1
         },
     }
Exemple #5
0
 def test_serialize(self):
     response = serialize(Prepend("foo", 1))
     assert response == {
         "UpdateExpression": "SET #ref1 = list_append(:val1, #ref1) ",
         "ExpressionAttributeNames": {
             "#ref1": "foo"
         },
         "ExpressionAttributeValues": {
             ":val1": 1
         },
     }
Exemple #6
0
 def test_serialize_if_not_exists(self):
     response = serialize(Set("foo", "bar", if_not_exists="biz"))
     assert response == {
         "UpdateExpression": "SET #ref1 = if_not_exists(#ref1b, :val1) ",
         "ExpressionAttributeNames": {
             "#ref1": "foo",
             "#ref1b": "biz"
         },
         "ExpressionAttributeValues": {
             ":val1": "bar"
         },
     }
Exemple #7
0
 def test_serialize_dict_updates(self):
     response = serialize({"foo": "bar", "biz": 5})
     assert response == {
         "UpdateExpression": "SET #ref1 = :val1, #ref2 = :val2 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo",
             "#ref2": "biz"
         },
         "ExpressionAttributeValues": {
             ":val1": "bar",
             ":val2": 5
         },
     }
Exemple #8
0
 def test_serialize_if_not_exists(self):
     response = serialize(Prepend("foo", 1, if_not_exists="biz"))
     assert response == {
         "UpdateExpression":
         "SET #ref1 = if_not_exists(#ref1b, list_append(:val1, #ref1)) ",
         "ExpressionAttributeNames": {
             "#ref1": "foo",
             "#ref1b": "biz"
         },
         "ExpressionAttributeValues": {
             ":val1": 1
         },
     }
Exemple #9
0
 def test_serialize_multiple_expressions(self):
     response = serialize([Set("foo", "bar"), Set("biz", 5), Add("bar", 2)])
     assert response == {
         "UpdateExpression":
         "SET #ref1 = :val1, #ref2 = :val2 ADD #ref3 :val3 ",
         "ExpressionAttributeNames": {
             "#ref1": "foo",
             "#ref2": "biz",
             "#ref3": "bar",
         },
         "ExpressionAttributeValues": {
             ":val1": "bar",
             ":val2": 5,
             ":val3": 2
         },
     }