Commits

Hadrien David  committed aef9952

Update dependencies by adding requirements files.
Fix tests which where using old version of webtest.
Fix some style issue in edited tests.

  • Participants
  • Parent commits e293ba4

Comments (0)

Files changed (18)

File development.ini

 [server:main]
 use = egg:waitress#main
 host = 0.0.0.0
-port = 6543
+port = 5000
 
 # Begin logging configuration
 
 keys = generic
 
 [logger_root]
-level = INFO
+level = DEBUG
 handlers = console
 
 [logger_ddbmock]

File requirements-dev.txt

+-r requirements-test.txt
+
+Sphinx
+ipdb

File requirements-test.txt

+
+d2to1
+boto
+nose
+nosexcover
+coverage
+mock
+webtest
+yanc
     Programming Language :: Python
     Programming Language :: Python :: 2.7
     License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
+
 requires-dist =
     pyramid
-    onctuous >= 0.5.1
+    onctuous >= 0.5.84
 
 [noah]
 public = True
-# -*- coding: utf-8 -*-
 
 from setuptools import setup, find_packages
 
-setup_requires = [
-    'd2to1',
-    'boto',
-    'nose',
-    'nosexcover',
-    'coverage',
-    'mock',
-    'webtest',
-    'Sphinx',
-]
-
 setup(
     d2to1=True,
     keywords='pyramid dynamodb mock planification',
     packages=find_packages(),
     include_package_data=True,
     zip_safe=False,
-    setup_requires=setup_requires,
+    setup_requires=['d2to1'],
     test_suite='nose.collector',
     entry_points="""\
     [paste.app_factory]

File tests/functional/pyramid/test_batch_get_item.py

 # -*- coding: utf-8 -*-
+import json
+import unittest
 
-import unittest, json
 
 TABLE_NAME1 = 'Table-HR'
 TABLE_NAME2 = 'Table-H'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestBatchGetItem(unittest.TestCase):
     def setUp(self):
         self.t1 = Table(TABLE_NAME1, TABLE_RT, TABLE_WT, hash_key, range_key)
         self.t2 = Table(TABLE_NAME2, TABLE_RT, TABLE_WT, hash_key, None)
 
-        dynamodb.data[TABLE_NAME1]  = self.t1
-        dynamodb.data[TABLE_NAME2]  = self.t2
+        dynamodb.data[TABLE_NAME1] = self.t1
+        dynamodb.data[TABLE_NAME2] = self.t2
 
         self.t1.put(ITEM1, {})
         self.t1.put(ITEM2, {})
         dynamodb.hard_reset()
 
     def test_batch_get_item_filter_one(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             u"RequestItems": {
                 TABLE_NAME1: {
                     u"Keys": [
-                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1}, u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}},
-                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1}, u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}},
-                    ],
+                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1},
+                         u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1},
+                         },
+                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1},
+                         u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}
+                         },
+                        ],
                     u"AttributesToGet": [u"relevant_data"],
-                },
+                    },
                 TABLE_NAME2: {
                     u"Keys": [
                         {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE3}},
-                    ],
-                },
+                        ],
+                    },
+                }
             }
-        }
 
         expected = {
             "Responses": {
                 },
                 "Table-H": {
                     "Items": [
-                        {"relevant_data": {"S": "tutu"}, "hash_key": {"N": "789"}, "range_key": {"S": "Waldo-5"}},
+                        {"relevant_data": {"S": "tutu"},
+                         "hash_key": {"N": "789"},
+                         "range_key": {"S": "Waldo-5"}
+                         },
                     ],
                     "ConsumedCapacityUnits": 0.5
                 }
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
     def test_batch_get_item_filter_one_consistent(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             u"RequestItems": {
                 TABLE_NAME1: {
                     u"Keys": [
-                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1}, u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}},
-                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1}, u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}},
-                    ],
+                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1},
+                         u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}
+                         },
+                        {u"HashKeyElement": {TABLE_HK_TYPE: HK_VALUE1},
+                         u"RangeKeyElement": {TABLE_RK_TYPE: RK_VALUE1}
+                         },
+                        ],
                     u"AttributesToGet": [u"relevant_data"],
                     u"ConsistentRead": True,
                 },
                 },
                 "Table-H": {
                     "Items": [
-                        {"relevant_data": {"S": "tutu"}, "hash_key": {"N": "789"}, "range_key": {"S": "Waldo-5"}},
+                        {"relevant_data": {"S": "tutu"},
+                         "hash_key": {"N": "789"},
+                         "range_key": {"S": "Waldo-5"}
+                         },
                     ],
                     "ConsumedCapacityUnits": 0.5
                 }
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_batch_write_item.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME1 = 'Table-HR'
 TABLE_NAME2 = 'Table-H'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestBatchWriteItem(unittest.TestCase):
     def setUp(self):
         self.t1 = Table(TABLE_NAME1, TABLE_RT, TABLE_WT, hash_key, range_key)
         self.t2 = Table(TABLE_NAME2, TABLE_RT, TABLE_WT, hash_key, None)
 
-        dynamodb.data[TABLE_NAME1]  = self.t1
-        dynamodb.data[TABLE_NAME2]  = self.t2
+        dynamodb.data[TABLE_NAME1] = self.t1
+        dynamodb.data[TABLE_NAME2] = self.t2
 
         self.t1.put(ITEM1, {})
         self.t2.put(ITEM4, {})
         dynamodb.hard_reset()
 
     def test_batch_write_item(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             u"RequestItems": {
                 TABLE_NAME1: [
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_create_table.py

-# -*- coding: utf-8 -*-
+import json
+import time
+import unittest
 
-import unittest, mock, json, time
+import mock
 
 NOW = time.time()
 
 TABLE_RT = 45
 TABLE_WT = 123
 
-HASH_KEY = {"AttributeName":"hash_key","AttributeType":"N"}
-RANGE_KEY = {"AttributeName":"range_key","AttributeType":"S"}
+HASH_KEY = {"AttributeName": "hash_key", "AttributeType": "N"}
+RANGE_KEY = {"AttributeName": "range_key", "AttributeType": "S"}
 
 HEADERS = {
     'x-amz-target': 'dynamodb_20111205.CreateTable',
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestCreateTable(unittest.TestCase):
     def setUp(self):
             }
         }
 
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
         data = dynamodb.data
         assert TABLE_NAME1 in data
         self.assertEqual(HASH_KEY['AttributeType'], table.hash_key.typename)
         self.assertEqual(RANGE_KEY['AttributeType'], table.range_key.typename)
 
-    # The real goal of this test is to validate the error view. The tested behavior
+    # The real goal of this test is to validate the error view.
+    # The tested behavior
     # is already known to work thanks the boto tests
     def test_create_table_twice_fails(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME1,
             "KeySchema": {
         }
 
         expected = {
-            u'__type': u'com.amazonaws.dynamodb.v20111205#ResourceInUseException',
+            u'__type': 'com.amazonaws.dynamodb.'
+                       'v20111205#ResourceInUseException',
             u'message': u'Table {} already exists'.format(TABLE_NAME1),
         }
 
-
-        res = self.app.post_json('/', request, HEADERS, status=200)
-        res = self.app.post_json('/', request, HEADERS, status=400)
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=400)
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
         self.assertEqual(expected, json.loads(res.body))

File tests/functional/pyramid/test_delete_item.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME = 'Table-HR'
 TABLE_NAME_404 = 'Waldo'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestDeleteItem(unittest.TestCase):
     def setUp(self):
         from ddbmock.database.table import Table
         from ddbmock.database.key import PrimaryKey
 
-        from ddbmock.database.db import dynamodb
         from ddbmock import main
         app = main({})
         from webtest import TestApp
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
 
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
         self.t1.put(ITEM, {})
 
     def tearDown(self):
         dynamodb.hard_reset()
 
     def test_delete_item_hr(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "Key": {
-                "HashKeyElement":  HK,
+                "HashKeyElement": HK,
                 "RangeKeyElement": RK,
             },
         }
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
         # Live data check
         self.assertNotIn((HK_VALUE, RK_VALUE), self.t1.store)

File tests/functional/pyramid/test_delete_table.py

-# -*- coding: utf-8 -*-
+import json
+import time
+import unittest
 
-import unittest, mock, json, time
+import mock
 
 NOW = time.time()
 
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestDeleteTable(unittest.TestCase):
     @mock.patch("ddbmock.database.table.time")  # Brrr
 
         hash_key = PrimaryKey(TABLE_HK_NAME, TABLE_HK_TYPE)
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
-        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key, status='ACTIVE')
+        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key,
+                   status='ACTIVE')
         dynamodb.data[TABLE_NAME] = t1
 
     def tearDown(self):
         dynamodb.hard_reset()
 
     def test_delete_table(self):
-        from ddbmock.database.db import dynamodb
-
         request = {"TableName": TABLE_NAME}
 
         expected = {
             }
         }
 
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_describe_table.py

-# -*- coding: utf-8 -*-
+import json
+import time
+import unittest
 
-import unittest, mock, json, time
+import mock
 
 NOW = time.time()
 
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestDescribeTable(unittest.TestCase):
     @mock.patch("ddbmock.database.table.time")  # Brrr
 
         hash_key = PrimaryKey(TABLE_HK_NAME, TABLE_HK_TYPE)
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
-        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key, status='ACTIVE')
+        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key,
+                   status='ACTIVE')
         dynamodb.data[TABLE_NAME] = t1
 
     def tearDown(self):
         dynamodb.hard_reset()
 
     def test_describe_table(self):
-        from ddbmock.database.db import dynamodb
-        from sys import getsizeof
-
         request = {"TableName": TABLE_NAME}
 
         expected = {
             }
         }
 
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_get_item.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME = 'Table-HR'
 TABLE_RT = 45
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestGetItem(unittest.TestCase):
     def setUp(self):
         from ddbmock.database.table import Table
         from ddbmock.database.key import PrimaryKey
 
-        from ddbmock.database.db import dynamodb
         from ddbmock import main
         app = main({})
         from webtest import TestApp
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
 
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
         self.t1.put(ITEM, {})
 
     def tearDown(self):
         dynamodb.hard_reset()
 
     def test_get_hr_attr_to_get(self):
-        from ddbmock.database.db import dynamodb
 
         request = {
             "TableName": TABLE_NAME,
             "Key": {
-                "HashKeyElement":  HK,
+                "HashKeyElement": HK,
                 "RangeKeyElement": RK,
             },
             "AttributesToGet": ["relevant_data"],
             }
         }
 
-
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_list_tables.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME1 = 'Table-1'
 TABLE_NAME2 = 'Table-2'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 class TestListTables(unittest.TestCase):
     def setUp(self):
         from ddbmock.database.db import dynamodb
 
     def test_list_tables(self):
         from ddbmock import connect_boto_patch
-        db = connect_boto_patch()
+        connect_boto_patch()
 
         request = {}
 
             "TableNames": [TABLE_NAME1, TABLE_NAME2],
         }
 
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_put_item.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME = 'Table-HR'
 TABLE_NAME_404 = 'Waldo'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestTODO(unittest.TestCase):
     def setUp(self):
         hash_key = PrimaryKey(TABLE_HK_NAME, TABLE_HK_TYPE)
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
         dynamodb.hard_reset()
 
     def test_put_hr(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "Item": ITEM,
         expected = {u'ConsumedCapacityUnits': 1}
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
         # Live data check
         self.assertEqual(ITEM, self.t1.store[HK_VALUE, RK_VALUE])
-

File tests/functional/pyramid/test_query.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME1 = 'Table-1'
 
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestQuery(unittest.TestCase):
     def setUp(self):
         from ddbmock.database.db import dynamodb
         from ddbmock.database.table import Table
         from ddbmock.database.key import PrimaryKey
-
-        from ddbmock.database.db import dynamodb
         from ddbmock import main
         app = main({})
         from webtest import TestApp
 
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
 
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
 
         self.t1.put(ITEM1, {})
         self.t1.put(ITEM2, {})
         dynamodb.hard_reset()
 
     def test_query_condition_filter_fields(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "HashKeyValue": {TABLE_HK_TYPE: HK_VALUE},
-            "RangeKeyCondition": {"AttributeValueList":[{"S":"Waldo-2"}],"ComparisonOperator":"GT"},
+            "RangeKeyCondition": {
+                "AttributeValueList": [{"S":"Waldo-2"}],
+                "ComparisonOperator": "GT",
+                },
             "AttributesToGet": [u'relevant_data'],
         }
 
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
     def test_query_count_and_attrs_to_get_fails(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "HashKeyValue": {TABLE_HK_TYPE: HK_VALUE},
-            "RangeKeyCondition": {"AttributeValueList":[{"S":"Waldo-2"}],"ComparisonOperator":"GT"},
+            "RangeKeyCondition": {
+                "AttributeValueList": [{"S":"Waldo-2"}],
+                "ComparisonOperator": "GT",
+                },
             "AttributesToGet": [u'relevant_data'],
             "Count": True,
         }
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=400)
+        res = self.app.post_json('/', request, headers=HEADERS, status=400)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
-
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_scan.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME1 = 'Table-1'
 
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestScan(unittest.TestCase):
     def setUp(self):
         from ddbmock.database.table import Table
         from ddbmock.database.key import PrimaryKey
 
-        from ddbmock.database.db import dynamodb
         from ddbmock import main
         app = main({})
         from webtest import TestApp
 
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
 
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
 
         self.t1.put(ITEM1, {})
         self.t1.put(ITEM2, {})
         dynamodb.hard_reset()
 
     def test_scan_condition_filter_fields(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "ScanFilter": {
                 "relevant_data": {
-                    "AttributeValueList": [{"S":"toto"},{"S":"titi"},{"S":"tata"}],
+                    "AttributeValueList": [
+                        {"S":"toto"},
+                        {"S":"titi"},
+                        {"S":"tata"},
+                        ],
                     "ComparisonOperator": "IN",
                 },
             },
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
     def test_scan_count_and_attrs_to_get_fails(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "ScanFilter": {
                 "relevant_data": {
-                    "AttributeValueList": [{"S":"toto"},{"S":"titi"},{"S":"tata"}],
+                    "AttributeValueList": [
+                        {"S":"toto"},
+                        {"S":"titi"},
+                        {"S":"tata"},
+                        ],
                     "ComparisonOperator": "IN",
                 },
             },
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=400)
+        res = self.app.post_json('/', request, headers=HEADERS, status=400)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])

File tests/functional/pyramid/test_update_item.py

-# -*- coding: utf-8 -*-
-
-import unittest, json
+import json
+import unittest
 
 TABLE_NAME = 'Table-HR'
 TABLE_NAME_404 = 'Waldo'
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestUpdateItem(unittest.TestCase):
     def setUp(self):
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
 
         self.t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key)
-        dynamodb.data[TABLE_NAME]  = self.t1
+        dynamodb.data[TABLE_NAME] = self.t1
         self.t1.put(ITEM, {})
 
     def tearDown(self):
         dynamodb.hard_reset()
 
     def test_update_item_put_hr(self):
-        from ddbmock.database.db import dynamodb
-
         request = {
             "TableName": TABLE_NAME,
             "Key": {
                 "HashKeyElement": HK,
                 "RangeKeyElement": RK,
             },
-            "AttributeUpdates":{'relevant_data': {'Value': RELEVANT_FIELD}},
+            "AttributeUpdates": {'relevant_data': {'Value': RELEVANT_FIELD}},
         }
         expected = {"ConsumedCapacityUnits": 1}
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
         # Live data check
-        self.assertEqual(RELEVANT_FIELD, self.t1.store[HK_VALUE, RK_VALUE]['relevant_data'])
+        self.assertEqual(RELEVANT_FIELD,
+                         self.t1.store[HK_VALUE, RK_VALUE]['relevant_data'])

File tests/functional/pyramid/test_update_table.py

-# -*- coding: utf-8 -*-
+import json
+import time
+import unittest
 
-import unittest, mock, json, time
+import mock
 
 NOW = time.time()
-NOW2 = time.time() + 42*1000
+NOW2 = time.time() + 42 * 1000
 
 TABLE_NAME = 'Table-1'
 TABLE_RT = 45
     'content-type': 'application/x-amz-json-1.0',
 }
 
+
 # Goal here is not to test the full API, this is done by the Boto tests
 class TestUpdateTable(unittest.TestCase):
     @mock.patch("ddbmock.database.table.time")  # Brrr
 
         hash_key = PrimaryKey(TABLE_HK_NAME, TABLE_HK_TYPE)
         range_key = PrimaryKey(TABLE_RK_NAME, TABLE_RK_TYPE)
-        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key, status="ACTIVE")
+        t1 = Table(TABLE_NAME, TABLE_RT, TABLE_WT, hash_key, range_key,
+                   status="ACTIVE")
         dynamodb.data[TABLE_NAME] = t1
 
-
     def tearDown(self):
         from ddbmock.database.db import dynamodb
         dynamodb.hard_reset()
                 u'CreationDateTime': NOW,
                 u'ItemCount': 0,
                 u'KeySchema': {
-                    u'HashKeyElement': {u'AttributeName': u'hash_key', u'AttributeType': u'N'},
-                    u'RangeKeyElement': {u'AttributeName': u'range_key', u'AttributeType': u'S'},
+                    u'HashKeyElement': {
+                        u'AttributeName': u'hash_key',
+                        u'AttributeType': u'N',
+                        },
+                    u'RangeKeyElement': {
+                        u'AttributeName': u'range_key',
+                        u'AttributeType': u'S',
+                        },
                 },
                 u'ProvisionedThroughput': {
                     u'LastDecreaseDateTime': NOW2,
         }
 
         # Protocol check
-        res = self.app.post_json('/', request, HEADERS, status=200)
+        res = self.app.post_json('/', request, headers=HEADERS, status=200)
         self.assertEqual(expected, json.loads(res.body))
-        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8', res.headers['Content-Type'])
+        self.assertEqual('application/x-amz-json-1.0; charset=UTF-8',
+                         res.headers['Content-Type'])
 
         # Live data check
         data = dynamodb.data