<s> import mock <EOL> import unittest <EOL> class TestRequirePostgresDatabase ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_params_respected ( self , database_exists , run , create_database , <EOL> require_locale , restarted , service_name ) : <EOL> """<STR_LIT>""" <EOL> from fabtools import require <EOL> database_exists . return_value = False <EOL> run . return_value = '<STR_LIT>' <EOL> require . postgres . database ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , locale = '<STR_LIT>' , <EOL> encoding = '<STR_LIT>' , <EOL> template = '<STR_LIT>' ) <EOL> run . assert_called_with ( '<STR_LIT>' ) <EOL> require_locale . assert_called_with ( '<STR_LIT>' ) <EOL> create_database . assert_called_with ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , locale = '<STR_LIT>' , <EOL> encoding = '<STR_LIT>' , <EOL> template = '<STR_LIT>' ) <EOL> class TestRequirePostgresUser ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_require_user_exists ( self , user_exists , create_user ) : <EOL> user_exists . return_value = True <EOL> from fabtools import require <EOL> require . postgres . user ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> user_exists . assert_called_with ( '<STR_LIT:foo>' ) <EOL> self . assertEqual ( [ ] , create_user . method_calls ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_require_user_with_default_options ( self , user_exists , create_user ) : <EOL> user_exists . return_value = False <EOL> from fabtools import require <EOL> require . postgres . user ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> create_user . assert_called_with ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , False , False , False , True , <EOL> True , None , False ) <EOL> class TestPostgresCreateUser ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_create_user_with_no_options ( self , _run_as_pg ) : <EOL> from fabtools import postgres <EOL> postgres . create_user ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) <EOL> expected = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( expected , _run_as_pg . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_create_user_with_no_connection_limit ( self , _run_as_pg ) : <EOL> from fabtools import postgres <EOL> postgres . create_user ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , connection_limit = - <NUM_LIT:1> ) <EOL> expected = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( expected , _run_as_pg . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_create_user_with_custom_options ( self , _run_as_pg ) : <EOL> from fabtools import postgres <EOL> postgres . create_user ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , superuser = True , createdb = True , <EOL> createrole = True , inherit = False , login = False , <EOL> connection_limit = <NUM_LIT:20> , encrypted_password = True ) <EOL> expected = ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( expected , _run_as_pg . call_args [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] ) <EOL> class TestPostgresDropUser ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_drop_user ( self , _run_as_pg ) : <EOL> from fabtools . postgres import drop_user <EOL> drop_user ( '<STR_LIT:foo>' ) <EOL> _run_as_pg . assert_called_with ( '<STR_LIT>' ) <EOL> class TestPostgresDropDatabase ( unittest . TestCase ) : <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_drop_database ( self , _run_as_pg ) : <EOL> from fabtools . postgres import drop_database <EOL> drop_database ( '<STR_LIT:foo>' ) <EOL> _run_as_pg . assert_called_with ( '<STR_LIT>' ) </s>
