def test_action_delete(self): from ddbmock.database.item import Item # field does not exist (just ignores) item = Item({}) item._apply_action(FIELDNAME, {"Action": "DELETE", "Value": VALUE_S}) self.assertEqual([], item.items()) # delete scalar value item = Item({ FIELDNAME: VALUE_S, }) item._apply_action(FIELDNAME, {"Action": "DELETE"}) self.assertEqual([], item.items()) # delete set from set item = Item({ FIELDNAME: VALUE_SS, }) item._apply_action(FIELDNAME, { "Action": "DELETE", "Value": VALUE_SS_DEL }) self.assertEqual([(FIELDNAME, VALUE_SS_SUR)], item.items()) # delete set all from set item = Item({ FIELDNAME: VALUE_SS, }) item._apply_action(FIELDNAME, {"Action": "DELETE", "Value": VALUE_SS}) self.assertEqual([], item.items())
def test_action_delete(self): from ddbmock.database.item import Item # field does not exist (just ignores) item = Item({}) item._apply_action(FIELDNAME, {"Action": "DELETE", "Value": VALUE_S}) self.assertEqual([], item.items()) # delete scalar value item = Item({ FIELDNAME: VALUE_S, }) item._apply_action(FIELDNAME, {"Action": "DELETE"}) self.assertEqual([], item.items()) # delete set from set item = Item({ FIELDNAME: VALUE_SS, }) item._apply_action(FIELDNAME, {"Action": "DELETE", "Value": VALUE_SS_DEL}) self.assertEqual([(FIELDNAME, VALUE_SS_SUR)], item.items()) # delete set all from set item = Item({ FIELDNAME: VALUE_SS, }) item._apply_action(FIELDNAME, {"Action": "DELETE", "Value": VALUE_SS}) self.assertEqual([], item.items())
def test_action_add(self): from ddbmock.database.item import Item # add value to int field item = Item({FIELDNAME: VALUE_N}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_N}) self.assertEqual([(FIELDNAME, VALUE_N_X2)], item.items()) # push value to any set item = Item({FIELDNAME: VALUE_SS}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_SS_DEL}) self.assertEqual([(FIELDNAME, VALUE_SS_RES)], item.items()) # field does not exist item = Item({}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_NS}) self.assertEqual([(FIELDNAME, VALUE_NS)], item.items()) # add string set to non existing field item = Item({}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_SS}) self.assertEqual([(FIELDNAME, VALUE_SS)], item.items())
def test_action_add(self): from ddbmock.database.item import Item # add value to int field item = Item({FIELDNAME: VALUE_N}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_N}) self.assertEqual([(FIELDNAME, VALUE_N_X2)], item.items()) # push value to any set item = Item({FIELDNAME: VALUE_SS}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_SS_DEL}) self.assertEqual([(FIELDNAME, VALUE_SS_RES)], item.items()) # field does not exist item = Item({}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_NS}) self.assertEqual([(FIELDNAME, VALUE_NS)], item.items()) # add string set to non existing field item = Item({}) item._apply_action(FIELDNAME, {"Action": "ADD", "Value": VALUE_SS}) self.assertEqual([(FIELDNAME, VALUE_SS)], item.items())
def test_action_put(self): from ddbmock.database.item import Item item = Item({}) item._apply_action(FIELDNAME, {"Action": "PUT", "Value": VALUE_S}) self.assertEqual([(FIELDNAME, VALUE_S)], item.items())
def test_action_put(self): from ddbmock.database.item import Item item = Item({}) item._apply_action(FIELDNAME, {"Action": "PUT", "Value": VALUE_S}) self.assertEqual([(FIELDNAME, VALUE_S)], item.items())