<s> """<STR_LIT>""" <EOL> from cStringIO import StringIO <EOL> from django . core . management import call_command <EOL> from mock import patch <EOL> from tests import case <EOL> class CreateDefaultRolesTest ( case . DBTestCase ) : <EOL> """<STR_LIT>""" <EOL> def call_command ( self , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> with patch ( "<STR_LIT>" , StringIO ( ) ) as stdout : <EOL> call_command ( "<STR_LIT>" , ** kwargs ) <EOL> stdout . seek ( <NUM_LIT:0> ) <EOL> return stdout . read ( ) <EOL> def assertRoles ( self , * groups ) : <EOL> """<STR_LIT>""" <EOL> self . assertEqual ( <EOL> set ( [ g . name for g in self . model . Role . objects . all ( ) ] ) , <EOL> set ( groups ) <EOL> ) <EOL> def test_creates_roles ( self ) : <EOL> """<STR_LIT>""" <EOL> self . call_command ( ) <EOL> self . assertRoles ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_skips_existing_roles ( self ) : <EOL> """<STR_LIT>""" <EOL> self . model . Role . objects . create ( name = "<STR_LIT>" ) <EOL> output = self . call_command ( ) <EOL> self . assertIn ( "<STR_LIT>" , output ) <EOL> self . assertRoles ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) <EOL> def test_unknown_permission ( self ) : <EOL> """<STR_LIT>""" <EOL> with patch ( <EOL> "<STR_LIT>" , <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] } ) : <EOL> output = self . call_command ( ) <EOL> self . assertIn ( "<STR_LIT>" , output ) <EOL> self . assertRoles ( "<STR_LIT>" ) <EOL> def test_normal_output ( self ) : <EOL> """<STR_LIT>""" <EOL> output = self . call_command ( ) <EOL> expected = """<STR_LIT>""" <EOL> self . assertEqual ( output , expected ) <EOL> def test_creates_all_quietly ( self ) : <EOL> """<STR_LIT>""" <EOL> output = self . call_command ( verbosity = <NUM_LIT:0> ) <EOL> self . assertEqual ( output , "<STR_LIT>" ) <EOL> def test_skips_existing_roles_quietly ( self ) : <EOL> """<STR_LIT>""" <EOL> self . model . Role . objects . create ( name = "<STR_LIT>" ) <EOL> output = self . call_command ( verbosity = <NUM_LIT:0> ) <EOL> self . assertEqual ( output , "<STR_LIT>" ) <EOL> def test_skips_unknown_permission_quietly ( self ) : <EOL> """<STR_LIT>""" <EOL> with patch ( <EOL> "<STR_LIT>" , <EOL> { "<STR_LIT>" : [ "<STR_LIT>" ] } ) : <EOL> output = self . call_command ( verbosity = <NUM_LIT:0> ) <EOL> self . assertEqual ( output , "<STR_LIT>" ) </s>
