Esempio n. 1
0
 def test_exception_when_no_key(self):
     """should thrown an exception if the response does not have a value for
     the primary_key attribute"""
     adapter = SuccessAdapter()
     adapter.response.parsed = None
     bridge = ModelBridge(adapter)
     self.assertRaises(KeyError, bridge, **self.options)
Esempio n. 2
0
    def test_resets_caching(self):
        self.called_foo = False
        def foo():
            self.called_foo = True

        caching.register(foo)
        ModelBridge(SuccessAdapter())(**self.options)
        self.assertEqual(self.called_foo, True)
Esempio n. 3
0
 def test_freeze(self):
     """should freeze the model on success"""
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(self.model.frozen(), True)
Esempio n. 4
0
 def test_no_exception_without_read(self):
     """should not throw an exception if no read adapter is configured"""
     del self.model_class.reader
     adapter = SuccessAdapter()
     adapter.response.parsed = None
     ModelBridge(adapter)(**self.options)
Esempio n. 5
0
 def test_new_record_success(self):
     """should set the model's new_record attribute to false on success"""
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(self.model.new_record, False)
Esempio n. 6
0
 def test_set_key(self):
     """should set the model's primary_key attribute on success"""
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(self.model.id, 42)
Esempio n. 7
0
 def test_skip_reload(self):
     """should not reload the model if no read adapter is available"""
     del self.model_class.reader
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(len(TestAdapter.calls), 0)
Esempio n. 8
0
 def test_reload_on_success(self):
     """should reload the model on success"""
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(len(TestAdapter.calls), 1)
Esempio n. 9
0
 def test_saved_on_success(self):
     """should set model's saved attribute to true on success"""
     ModelBridge(SuccessAdapter())(**self.options)
     self.assertEqual(self.model.saved, True)