1- from wagtail import hooks
2-
31from django .urls import reverse
4- from wagtail .test .utils import WagtailPageTestCase
2+
3+ from wagtail import hooks
54from wagtail .models import Page , Site
5+ from wagtail .test .utils import WagtailPageTestCase
66
77from common .models .settings import (
88 SearchSettings ,
99)
10+ from dashboard .wagtail_hooks import add_shortcuts_panel
11+ from incident .models import PrepublicationIncidentSync
1012from incident .tests .factories import (
1113 IncidentIndexPageFactory ,
1214)
13- from dashboard .wagtail_hooks import add_shortcuts_panel
1415
1516
1617class ShortcutsPanelTest (WagtailPageTestCase ):
@@ -37,3 +38,21 @@ def test_image_shortcut(self):
3738 def test_incident_shortcut (self ):
3839 response = self .client .get (reverse ('wagtailadmin_home' ))
3940 self .assertContains (response , 'Add a new incident' )
41+
42+ @hooks .register_temporarily ('construct_homepage_panels' , add_shortcuts_panel )
43+ def test_prepublication_status (self ):
44+ prepub_sync = PrepublicationIncidentSync .objects .create (
45+ status = PrepublicationIncidentSync .Status .SUCCESS ,
46+ message = '3 incidents retrieved.' ,
47+ )
48+ response = self .client .get (reverse ('wagtailadmin_home' ))
49+ self .assertContains (response , '3 incidents retrieved.' )
50+
51+ @hooks .register_temporarily ('construct_homepage_panels' , add_shortcuts_panel )
52+ def test_prepublication_sync_failed_message (self ):
53+ prepub_sync = PrepublicationIncidentSync .objects .create (
54+ status = PrepublicationIncidentSync .Status .INVALID_DATA ,
55+ message = 'Row 3: Invalid date Jan 13, 2010' ,
56+ )
57+ response = self .client .get (reverse ('wagtailadmin_home' ))
58+ self .assertContains (response , 'Sync did not succeed' )
0 commit comments