<s> from django . contrib . auth . models import User <EOL> from django . core . urlresolvers import reverse <EOL> from django . db import IntegrityError <EOL> from django . test import TestCase <EOL> from django . test . client import Client <EOL> from lfs . tests . utils import DummyRequest <EOL> from lfs . page . models import Page <EOL> class PageTestCase ( TestCase ) : <EOL> """<STR_LIT>""" <EOL> fixtures = [ '<STR_LIT>' , "<STR_LIT>" ] <EOL> def setUp ( self ) : <EOL> """<STR_LIT:U+0020>""" <EOL> self . client . login ( username = "<STR_LIT>" , password = "<STR_LIT>" ) <EOL> self . user = User . objects . get ( username = "<STR_LIT>" ) <EOL> self . request = DummyRequest ( user = self . user ) <EOL> self . root = Page . objects . create ( <EOL> id = <NUM_LIT:1> , <EOL> title = "<STR_LIT>" , <EOL> slug = "<STR_LIT>" , <EOL> exclude_from_navigation = False , <EOL> ) <EOL> self . page = Page . objects . create ( <EOL> id = <NUM_LIT:2> , <EOL> title = "<STR_LIT>" , <EOL> slug = "<STR_LIT>" , <EOL> body = "<STR_LIT>" , <EOL> short_text = "<STR_LIT>" <EOL> ) <EOL> def test_add_page ( self ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( self . page . id , <NUM_LIT:2> ) <EOL> self . assertEqual ( self . page . title , "<STR_LIT>" ) <EOL> self . assertEqual ( self . page . slug , "<STR_LIT>" ) <EOL> self . assertEqual ( self . page . body , "<STR_LIT>" ) <EOL> self . assertEqual ( self . page . active , False ) <EOL> self . assertEqual ( self . page . position , <NUM_LIT> ) <EOL> def test_page_view_1 ( self ) : <EOL> """<STR_LIT>""" <EOL> url = reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : self . page . slug } ) <EOL> response = self . client . get ( url ) <EOL> self . failIf ( response . content . find ( "<STR_LIT>" ) == - <NUM_LIT:1> ) <EOL> self . failIf ( response . content . find ( "<STR_LIT>" ) == - <NUM_LIT:1> ) <EOL> def test_page_view_2 ( self ) : <EOL> """<STR_LIT>""" <EOL> self . client . logout ( ) <EOL> url = reverse ( "<STR_LIT>" , kwargs = { "<STR_LIT>" : self . page . slug } ) <EOL> response = self . client . get ( url ) <EOL> self . failIf ( response . content . find ( "<STR_LIT>" ) == - <NUM_LIT:1> ) <EOL> self . page . active = True <EOL> self . page . save ( ) <EOL> response = self . client . get ( url ) <EOL> self . failIf ( response . content . find ( "<STR_LIT>" ) == - <NUM_LIT:1> ) <EOL> self . failIf ( response . content . find ( "<STR_LIT>" ) == - <NUM_LIT:1> ) <EOL> def test_active_pages ( self ) : <EOL> """<STR_LIT>""" <EOL> pages = Page . objects . active ( ) <EOL> self . assertEqual ( len ( pages ) , <NUM_LIT:0> ) <EOL> self . page . active = True <EOL> self . page . save ( ) <EOL> pages = Page . objects . active ( ) <EOL> self . assertEqual ( len ( pages ) , <NUM_LIT:1> ) <EOL> def test_get_meta_title ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_title ( ) ) <EOL> self . page . meta_title = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_title ( ) ) <EOL> self . page . meta_title = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_title ( ) ) <EOL> self . page . meta_title = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_title ( ) ) <EOL> def test_get_meta_keywords ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_keywords ( ) ) <EOL> self . page . meta_keywords = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_keywords ( ) ) <EOL> self . page . meta_keywords = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_keywords ( ) ) <EOL> self . page . meta_keywords = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_keywords ( ) ) <EOL> self . page . meta_keywords = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_keywords ( ) ) <EOL> def test_get_meta_description ( self ) : <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_description ( ) ) <EOL> self . page . meta_description = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_description ( ) ) <EOL> self . page . meta_description = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_description ( ) ) <EOL> self . page . meta_description = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_description ( ) ) <EOL> self . page . meta_description = "<STR_LIT>" <EOL> self . page . save ( ) <EOL> self . assertEqual ( "<STR_LIT>" , self . page . get_meta_description ( ) ) <EOL> def test_add_page_with_existing_slug ( self ) : <EOL> next_id = Page . objects . count ( ) + <NUM_LIT:1> <EOL> Page . objects . create ( id = next_id , title = "<STR_LIT>" , slug = "<STR_LIT:test>" ) <EOL> self . assertRaises ( IntegrityError , Page . objects . create , id = next_id + <NUM_LIT:1> , title = "<STR_LIT>" , slug = "<STR_LIT:test>" ) </s>
