예제 #1
0
    def test_it_send_created_parameter_depending_for_updating(self):
        #defining the receiver
        def signal_receiver(sender, instance, created, **kwargs):
            if signal_receiver.times == 1:
                self.assertTrue(created)
            if signal_receiver.times == 2:
                self.assertFalse(created)


        signal_receiver = MethodCallLogger(signal_receiver)
        #connecting the thing
        election_finished.connect(signal_receiver)
        #creating
        Election.fetch_all_from_api()
        #updating
        Election.fetch_all_from_api()
예제 #2
0
    def test_a_signal_is_called(self):

        #defining the receiver
        def signal_receiver(sender, instance, created, **kwargs):
            self.assertIsInstance(instance, Election)
            self.assertEquals(sender, Election)
            self.assertTrue(created)


        signal_receiver = MethodCallLogger(signal_receiver)
        #connecting the thing
        election_finished.connect(signal_receiver)

        Election.fetch_all_from_api()

        self.assertTrue(signal_receiver.was_called)
        self.assertEquals(signal_receiver.times, 1)