示例#1
0
 def test_turn_on_save(self):
     """
     Tests turning on syncing for the save signal.
     """
     turn_off_syncing()
     turn_on_syncing()
     with patch('entity.models.sync_entity_signal_handler') as mock_handler:
         Account.objects.create()
         self.assertTrue(mock_handler.called)
示例#2
0
 def test_turn_on_bulk(self):
     """
     Tests turning on syncing for bulk operations.
     """
     turn_off_syncing()
     turn_on_syncing()
     with patch('entity.models.sync_entities_signal_handler') as mock_handler:
         Account.objects.bulk_create([Account() for i in range(5)])
         self.assertTrue(mock_handler.called)
示例#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)
示例#4
0
 def tearDown(self):
     super(TestTurnOnOffSyncing, self).tearDown()
     # Make sure syncing is always on before every test
     turn_on_syncing()