Commits

Jean-Tiare Le Bigot committed 921dc87

keep internal data and tests clean

  • Participants
  • Parent commits 83d8936

Comments (0)

Files changed (2)

File ddbmock/database/item.py

                 ftypename, fvalue = self[fieldname].items()[0]
 
                 if ftypename == u"N":
-                    self[fieldname][u"N"] = Decimal(value) + Decimal(fvalue)
+                    data = Decimal(value) + Decimal(fvalue)
+                    self[fieldname][u"N"] = unicode(data)
                 elif ftypename in [u"NS", u"SS", u"BS"]:
                     if ftypename != typename:
                         raise TypeError("Expected type {t} for ADD in type {t}. Got {}".format(typename, t=ftypename))
-                    self[fieldname][typename] = set(fvalue).union(value)
+                    data = set(fvalue).union(value)
+                    self[fieldname][typename] = list(data)
                 else:
                     TypeError("Only N, NS, SS and BS types supports ADD operation. Got {}".format(ftypename))
             else:

File ddbmock/tests/functional/boto/test_update_item.py

 
         ADD_VALUE = 2
 
-        expected = {u'N': Decimal(42 + ADD_VALUE)}
+        expected = {u'N': unicode(42 + ADD_VALUE)}
 
         # regular increment
         db.layer1.update_item(TABLE_NAME2, key, {
         self.assertEqual(expected, self.t2.data[HK_VALUE][False][FIELD_NUM_NAME])
 
     def test_update_item_push_to_set_ok(self):
-        # sometimes weird black magic types occures in test. these are related
-        # to internal "DB" logic. it does not affect real API output at all
         from ddbmock import connect_boto
         from boto.dynamodb.exceptions import DynamoDBValidationError
 
         db = connect_boto()
 
         expected1 = {u'SS': [u'item1', u'item2', u'item3', u'item4']}
-        expected2 = {u'SS': set([u'item1', u'item2', u'item3', u'item4', u'item5'])}
+        expected2 = {u'SS': [u'item2', u'item3', u'item1', u'item4', u'item5']}
 
         key = {
             u"HashKeyElement":  {TABLE_HK_TYPE: HK_VALUE},