<s> from __future__ import absolute_import , unicode_literals <EOL> from django . core . urlresolvers import reverse <EOL> from django . test import TestCase <EOL> from wagtail . tests . utils import WagtailTestUtils <EOL> from wagtail . wagtailadmin import widgets as wagtailadmin_widgets <EOL> from wagtail . wagtailcore import hooks <EOL> from wagtail . wagtailcore . models import Page <EOL> class TestButtonsHooks ( TestCase , WagtailTestUtils ) : <EOL> def setUp ( self ) : <EOL> self . root_page = Page . objects . get ( id = <NUM_LIT:2> ) <EOL> self . login ( ) <EOL> def test_register_page_listing_buttons ( self ) : <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_listing_buttons ( page , page_perms , is_parent = False ) : <EOL> yield wagtailadmin_widgets . PageListingButton ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> priority = <NUM_LIT:10> <EOL> ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = ( self . root_page . id , ) ) <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> def test_register_page_listing_more_buttons ( self ) : <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_listing_more_buttons ( page , page_perms , is_parent = False ) : <EOL> yield wagtailadmin_widgets . Button ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> priority = <NUM_LIT:10> <EOL> ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = ( self . root_page . id , ) ) <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> def test_custom_button_with_dropdown ( self ) : <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_custom_listing_buttons ( page , page_perms , is_parent = False ) : <EOL> yield wagtailadmin_widgets . ButtonWithDropdownFromHook ( <EOL> '<STR_LIT>' , <EOL> hook_name = '<STR_LIT>' , <EOL> page = page , <EOL> page_perms = page_perms , <EOL> is_parent = is_parent , <EOL> attrs = { '<STR_LIT:target>' : '<STR_LIT>' } , <EOL> priority = <NUM_LIT:50> <EOL> ) <EOL> @ hooks . register ( '<STR_LIT>' ) <EOL> def page_custom_listing_more_buttons ( page , page_perms , is_parent = False ) : <EOL> yield wagtailadmin_widgets . Button ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> priority = <NUM_LIT:10> <EOL> ) <EOL> response = self . client . get ( <EOL> reverse ( '<STR_LIT>' , args = ( self . root_page . id , ) ) <EOL> ) <EOL> self . assertEqual ( response . status_code , <NUM_LIT:200> ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertTemplateUsed ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) <EOL> self . assertContains ( response , '<STR_LIT>' ) </s>
