def test_error_in_html(self): """ Tests that the method get_projector_html does not raise any errors. """ get_projector_html = MagicMock(side_effect=Exception('no good error')) overlay = Overlay('test_overlay', lambda: 'widget_html', get_projector_html) with warnings.catch_warnings(record=True) as warning: overlay.get_projector_html() self.assertEqual(str(warning[0].message), 'Exception in overlay "test_overlay": no good error')
def test_error_in_html(self): """ Tests that the method get_projector_html does not raise any errors. """ get_projector_html = MagicMock(side_effect=Exception('no good error')) overlay = Overlay('test_overlay', lambda: 'widget_html', get_projector_html) with warnings.catch_warnings(record=True) as warning: overlay.get_projector_html() self.assertEqual( warning[0].message.message, 'Exception in overlay "test_overlay": no good error')
def test_error_in_html(self): """ Tests that the methof get_projector_html does not raise any errors. """ get_projector_html = MagicMock(side_effect=Exception('no good error')) overlay = Overlay('test_overlay', lambda: 'widget_html', get_projector_html) # Test in productive mode with patch('openslides.projector.projector.settings.DEBUG', False): self.assertEqual(overlay.get_projector_html(), '') # Test in debug mode with patch('openslides.projector.projector.settings.DEBUG', True): self.assertRaisesMessage( Exception, 'no good error', overlay.get_projector_html)
def agenda_list_of_speakers(sender, **kwargs): """ Receiver for the list of speaker overlay. """ name = 'agenda_speaker' def get_widget_html(): """ Returns the the html-code to show in the overly-widget. """ return render_to_string('agenda/overlay_speaker_widget.html') def get_projector_html(): """ Returns an html-code to show on the projector. The overlay is only shown on agenda-items and not on the list-of-speakers slide. """ slide = get_active_object() if slide is None or isinstance(slide, Item): item = slide else: # TODO: If there is more than one item, use the first one in the # mptt tree that is not closed. try: item = Item.objects.filter( content_type=ContentType.objects.get_for_model(slide), object_id=slide.pk)[0] except IndexError: item = None if item and get_active_slide().get('type', None) != 'list_of_speakers': list_of_speakers = item.get_list_of_speakers( old_speakers_count=config['agenda_show_last_speakers'], coming_speakers_count=5) value = render_to_string( 'agenda/overlay_speaker_projector.html', { 'list_of_speakers': list_of_speakers, 'closed': item.speaker_list_closed }) else: value = None return value return Overlay(name, get_widget_html, get_projector_html)
def agenda_list_of_speakers(sender, **kwargs): """ Receiver for the list of speaker overlay. """ name = 'agenda_speaker' def get_widget_html(): """ Returns the the html-code to show in the overly-widget. """ return render_to_string('agenda/overlay_speaker_widget.html') def get_projector_html(): """ Returns an html-code to show on the projector. """ slide = get_slide_from_sid(get_active_slide(only_sid=True), element=True) if not isinstance(slide, Item): # Only show list of speakers overlay on agenda items return None if config['presentation_argument'] == 'show_list_of_speakers': # Do not show list of speakers overlay on the list of speakers slide return None clear_projector_cache() list_of_speakers = slide.get_list_of_speakers( old_speakers_count=config['agenda_show_last_speakers'], coming_speakers_count=5) context = { 'list_of_speakers': list_of_speakers, 'closed': slide.speaker_list_closed, } return render_to_string('agenda/overlay_speaker_projector.html', context) return Overlay(name, get_widget_html, get_projector_html)