def test_save_supporter(self, MockClient): set_livesettings_value('Events', 'supporters-autonotify', True) mocked_client = MockClient.return_value = MockedEventsNotifierClient() event = EventFactory(type=Event.TYPE_SUPPORT) EventUpdateFactory(event=event, text='Test', location=Point(1, 2)) self.assertEqual(mocked_client.publish_count, 0)
def test_supporters_autonotify(self, mock_jabber): event1, event2 = EventFactory(), EventFactory() set_livesettings_value('Events', 'supporters-autonotify', False) EventUpdateFactory(event=event1) self.assertFalse(mock_jabber.notify_supporters.called) set_livesettings_value('Events', 'supporters-autonotify', True) EventUpdateFactory(event=event2) self.assertEqual(mock_jabber.notify_supporters.call_count, 1)
def test_save_victim(self, MockClient): set_livesettings_value('Events', 'supporters-autonotify', True) mocked_client = MockClient.return_value = MockedEventsNotifierClient() event = EventFactory(type=Event.TYPE_VICTIM) with override_settings(JABBER_DRY_RUN=False): EventUpdateFactory(event=event, text='Test', location=Point(1, 2)) mocked_client.assert_published_once() self.assertIn('Test', mocked_client.payload_string) self.assertIn('location type="hash"', mocked_client.payload_string)