Commits

Jean-Tiare Le Bigot committed 5011b82

fixed mocked.called_with and use self.assertRaises instead of @raises

  • Participants
  • Parent commits 0632954

Comments (0)

Files changed (1)

File dynamodb_mapper/tests/test_model.py

 
 import mock
 
-from nose.tools import raises
-
 from dynamodb_mapper.model import (ConnectionBorg, DynamoDBModel,
     autoincrement_int, MaxRetriesExceededError, MAX_RETRIES,
     ExpectedValueError, _python_to_dynamodb, _dynamodb_to_python, utc_tz,
 
         m_new_batch_list.assert_called_once()
 
-    @raises(ThroughputError)
     def test_create_table_bad_throughput(self):
-        table = ConnectionBorg().create_table(DoomEpisode, 2, 5, False)
+        self.assertRaises(
+            ThroughputError,
+            ConnectionBorg().create_table,
+            DoomEpisode, 2, 5, False
+        )
 
-    @raises(SchemaError)
     def test_create_table_no_name(self):
-        table = ConnectionBorg().create_table(NoTableName, 10, 5, False)
+        self.assertRaises(
+            SchemaError,
+            ConnectionBorg().create_table,
+            NoTableName, 10, 5, False
+        )
 
-    @raises(SchemaError)
     def test_create_table_no_hash(self):
-        table = ConnectionBorg().create_table(NoHashKey, 10, 5, False)
+        self.assertRaises(
+            SchemaError,
+            ConnectionBorg().create_table,
+            NoHashKey, 10, 5, False
+        )
 
-    @raises(SchemaError)
     def test_create_table_no_schema(self):
-        table = ConnectionBorg().create_table(NoSchema, 10, 5, False)
+        self.assertRaises(
+            SchemaError,
+            ConnectionBorg().create_table,
+            NoSchema, 10, 5, False
+        )
 
-    @raises(SchemaError)
     def test_create_table_autoinc_with_range(self):
-        table = ConnectionBorg().create_table(IncompatibleKeys, 10, 5, False)
+        self.assertRaises(
+            SchemaError,
+            ConnectionBorg().create_table,
+            IncompatibleKeys, 10, 5, False
+        )
 
     @mock.patch("dynamodb_mapper.model.boto")
     def test_create_table_hash_key(self, m_boto):
         # Default int with callable fallback
         self.assertEquals(42, _get_default_value(int, return_42))
 
-    @raises(TypeError)
     def test_incompatible_types_crash_constant(self):
         # Default unicode with int fallback should fail
-        _get_default_value(unicode, 42)
+        self.assertRaises(
+            TypeError,
+            _get_default_value,
+            unicode, 42
+        )
 
-    @raises(TypeError)
     def test_incompatible_types_crash_callable(self):
         # Default unicode with callable int fallback should fail
-        _get_default_value(unicode, return_42)
+        self.assertRaises(
+            TypeError,
+            _get_default_value,
+            unicode, return_42
+        )
 
 
 class TestDynamoDBModel(unittest.TestCase):
         m_defaulter.return_value = u"weak"
         d = PlayerStrength()
 
-        m_defaulter.called_with(unicode, u"weak")
+        m_defaulter.assert_called_with(unicode, u"weak")
         self.assertEquals(d.strength, u"weak")
 
     def test_init_from_args(self):
 
     @mock.patch("dynamodb_mapper.model.Item")
     @mock.patch("dynamodb_mapper.model.boto")
-    @raises(DynamoDBResponseError)
     def test_save_unhandled_exception(self, m_boto, m_item):
         m_item_instance = m_item.return_value
         error = DynamoDBResponseError(
         c.episode_id = 0
         c.name = "Knee-deep in the Dead"
 
-        c.save()
+        self.assertRaises(DynamoDBResponseError, c.save)
 
     @mock.patch("dynamodb_mapper.model.Item")
     @mock.patch("dynamodb_mapper.model.boto")
         m_batch_list.add_batch.assert_called_with(m_table, [(0, u'level1'), (1, u'level2')])
         assert m_batch_list.submit.called
 
-    @raises(ValueError)
     def test_get_batch_over_100(self):
-        DoomEpisode.get_batch(range(101));
+        self.assertRaises(
+            ValueError,
+            DoomEpisode.get_batch,
+            range(101)
+        )
 
     @mock.patch("dynamodb_mapper.model.ConnectionBorg.get_table")
     def test_query(self, m_get_table):