def ready(self): from student.account.models import User pre_create_historical_record.connect( receiver=add_history_ip_address, sender=User, dispatch_uid="my_unique_identifier")
def test_pre_create_historical_record_signal(self): def handler(sender, instance, **kwargs): self.signal_was_called = True self.signal_instance = instance self.signal_sender = sender pre_create_historical_record.connect(handler) p = Poll(question="what's up?", pub_date=today) p.save() self.assertTrue(self.signal_was_called) self.assertEqual(self.signal_instance, p) self.assertEqual(self.signal_sender, p.history.first().__class__)
def test_pre_create_historical_record_signal(self): def handler(sender, instance, **kwargs): self.signal_was_called = True self.signal_instance = instance self.signal_history_instance = kwargs["history_instance"] self.signal_sender = sender pre_create_historical_record.connect(handler) p = Poll(question="what's up?", pub_date=today) p.save() self.assertTrue(self.signal_was_called) self.assertEqual(self.signal_instance, p) self.assertIsNotNone(self.signal_history_instance) self.assertEqual(self.signal_sender, p.history.first().__class__)
def setUp(self): pre_create_historical_record.connect( add_dynamic_history_ip_address, sender=HistoricalPollWithHistoricalIPAddress, dispatch_uid="add_dynamic_history_ip_address", )