1. Ludia
  2. Untitled project
  3. dynamodb-mock

Commits

Jean-Tiare Le Bigot  committed 9d93304

full test coverage

  • Participants
  • Parent commits 3a4645b
  • Branches default

Comments (0)

Files changed (16)

File tests/functional/boto/test_batch_get_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_batch_get_item_nominal(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_batch_write_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_batch_write_item_nominal(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_create_table.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_create_table_hash_range(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_delete_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_delete_item_hr(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_delete_table.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_delete(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_describe_table.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_describe_table(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_get_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_get_hr(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_list_tables.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_list_tables(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_put_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_put_hr(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_query.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_query_all(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_scan.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_scan_all(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_update_item.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_update_item_put_hr(self):
         from ddbmock import connect_boto_patch

File tests/functional/boto/test_update_table.py

View file
  • Ignore whitespace
 
     def tearDown(self):
         from ddbmock.database.db import dynamodb
+        from ddbmock import clean_boto_patch
         dynamodb.hard_reset()
+        clean_boto_patch()
 
     def test_update(self):
         from ddbmock import connect_boto_patch

File tests/integration/test_boto.py

View file
  • Ignore whitespace
 # Just, skip this unless "--no-skip"
 if '--no-skip' in sys.argv:
     import os, imp, boto, unittest
-    from ddbmock import connect_boto_patch
+    from ddbmock import connect_boto_patch, clean_boto_patch
 
     # Load boto dir
     boto_dir = os.path.realpath(boto.__file__+'/../../')
     # clean up
     layer1_file.close()
     layer2_file.close()
+    clean_boto_patch()
 else:
     print "Boto Integration tests are slow hence disabled by default, enable them with '--no-skip'"
 

File tests/unit/test_db.py

View file
  • Ignore whitespace
     def test_internal_delet_table(self):
         from ddbmock.database import dynamodb
 
-
         # delete a table
         dynamodb._internal_delete_table(TABLE_NAME)
         self.assertNotIn(TABLE_NAME, dynamodb.data)
     def test_delete_table(self):
         from ddbmock.database import dynamodb
 
-
         dynamodb.delete_table(TABLE_NAME)
-
         dynamodb.data[TABLE_NAME].delete.assert_called_withassert_called_with(callback=dynamodb._internal_delete_table)
 

File tests/unit/test_ddbmock_init.py

View file
  • Ignore whitespace
 ENDPOINT = '{}:{}'.format(HOST, PORT)
 
 class TestDdbmockInit(unittest.TestCase):
+    def tearDown(self):
+        from ddbmock import clean_boto_patch
+        clean_boto_patch()
+
     def test_connect_boto_patch_patch(self):
-        from ddbmock import connect_boto_patch
+        from ddbmock import connect_boto_patch, real_boto, noop
         from ddbmock.router.boto import boto_router
 
         db = connect_boto_patch()
 
         self.assertEqual(boto_router, db.layer1.make_request.im_func)
+        self.assertEqual(noop, db.layer1.__init__.im_func)
+        self.assertNotEqual(real_boto['Layer1.make_request'], boto_router)
+        self.assertNotEqual(real_boto['Layer1.__init__'], noop)
+
+        # do it twice to make sure it is safe
+        db = connect_boto_patch()
+
+        self.assertEqual(boto_router, db.layer1.make_request.im_func)
+        self.assertEqual(noop, db.layer1.__init__.im_func)
+        self.assertNotEqual(real_boto['Layer1.make_request'], boto_router)
+        self.assertNotEqual(real_boto['Layer1.__init__'], noop)
 
     def test_connect_boto_patch_network(self):
         from ddbmock import connect_boto_network, clean_boto_patch
 
-        # make sure no patch is active first
         clean_boto_patch()
-
         db = connect_boto_network(HOST, PORT)
 
         self.assertEqual('ddbmock', db.layer1.region.name)