Esempio n. 1
0
 def test_turn_off_bulk(self):
     """
     Tests turning off syncing for bulk operations.
     """
     turn_off_syncing()
     with patch('entity.models.sync_entities_signal_handler') as mock_handler:
         Account.objects.bulk_create([Account() for i in range(5)])
         self.assertFalse(mock_handler.called)
Esempio n. 2
0
 def test_turn_off_save(self):
     """
     Tests turning off syncing for the save signal.
     """
     turn_off_syncing()
     with patch('entity.models.sync_entity_signal_handler') as mock_handler:
         Account.objects.create()
         self.assertFalse(mock_handler.called)
Esempio n. 3
0
 def test_turn_on_delete(self):
     """
     Tests turning on syncing for the delete signal.
     """
     turn_off_syncing()
     turn_on_syncing()
     with patch('entity.models.sync_entity_signal_handler') as mock_handler:
         a = Account.objects.create()
         self.assertEquals(mock_handler.call_count, 1)
         a.delete()
         self.assertEquals(mock_handler.call_count, 2)