Commits

Jean-Tiare Le Bigot  committed ca46689

add create_table functional test boto

  • Participants
  • Parent commits 1210901

Comments (0)

Files changed (3)

File ddbmock/__init__.py

 routes = {
     'BatchGetItem':   'batch_get_item',
     'BatchWriteItem': 'batch_write_item',
-    'CreateTable':    'batch_write_item',
+    'CreateTable':    'create_table',
     'DeleteItem':     'delete_item',
     'DeleteTable':    'delete_table',
     'DescribeTable':  'describe_table',
         target = routes[action]
         mod = import_module('ddbmock.views.{}'.format(target))
         func = getattr(mod, '_{}'.format(target))
-        return (200, json.dumps(func(post)))
-    except KeyError:
-        err = InternalFailure("Method: {} does not exist".format(action))
-    except ImportError:
-        err = InternalFailure("Method: {} not yet implemented".format(action))
+        return 200, json.dumps(func(post))
+    #except KeyError:
+    #    err = InternalFailure("Method: {} does not exist".format(action))
+    #except ImportError:
+    #    err = InternalFailure("Method: {} not yet implemented".format(action))
     except DDBError as e:
         err = e
 
     boto.perflog.info('dynamodb %s: id=%s time=%sms',
                       target, request_id, int(elapsed))
     boto.log.debug(ret)
+    # TODO: exception handling
     return json.loads(ret, object_hook=object_hook)

File ddbmock/database/table.py

 
         if u'HashKeyElement' not in data[u'KeySchema']:
             raise TypeError("No hash_key")
+        hash_key = PrimaryKey.from_dict(data[u'KeySchema'][u'HashKeyElement'])
+        range_key = None
         if u'RangeKeyElement' in data[u'KeySchema']:
             range_key = PrimaryKey.from_dict(data[u'KeySchema'][u'RangeKeyElement'])
-        hash_key = PrimaryKey.from_dict(data[u'KeySchema'][u'HashKeyElement'])
 
         return cls( data[u'TableName'],
                     data[u'ProvisionedThroughput'][u'ReadCapacityUnits'],

File ddbmock/views/create_table.py

 # -*- coding: utf-8 -*-
 
 from pyramid.view import view_config
-from ddbmock.database import DynamoDB, PrimaryKey
+from ddbmock.database import DynamoDB
 from ddbmock.errors import *
 
 # Real work
 @WrapExceptions
 def _create_table(post):
-    post = request.json
-
     table = DynamoDB().create_table(post[u'TableName'], post)
 
     if table is None: