def test_set_custom_bucket_name(self, _input, os): os.environ.get.return_value = 'mcgee' _input.return_value = 'booya' config = FileConfig() config.collect_settings(settings_to_get=['bucket']) eq_(config._parser.get('catsnap', 'bucket'), 'booya')
def test_get_catsnap_config(self, _input, os): os.environ.get.return_value = 'mcgee' _input.return_value = '' config = FileConfig() config.collect_settings() _input.assert_has_calls([ call("Would you like to print a fake file extension on urls? ")]) eq_(config._parser.get('catsnap', 'extension'), None)
def test_set_only_one_setting_name(self, _input): config = FileConfig() self._set_parser_defaults(config._parser) _input.return_value = 'truckit' config.collect_settings(settings_to_get=['bucket']) _input.assert_called_once_with("Please name your bucket (leave blank " "to use 'mypics'): ") eq_(config._parser.get('catsnap', 'bucket'), 'truckit')
def test_get_credentials(self, getpass, _input): getpass.getpass.return_value = 'secret access key' _input.return_value = 'access key id' config = FileConfig() config.collect_settings() eq_(config._parser.get('catsnap', 'api_host'), 'access key id') eq_(config._parser.get('catsnap', 'api_key'), 'secret access key')
def test_entering_nothing_changes_nothing(self, _input, getpass, os): os.environ.__getitem__.return_value = 'mcgee' config = FileConfig() self._set_parser_defaults(config._parser) _input.return_value = '' getpass.getpass.return_value = '' config.collect_settings() eq_(config._parser.get('Credentials', 'aws_access_key_id'), 'itsme') eq_(config._parser.get('Credentials', 'aws_secret_access_key'), 'letmein') eq_(config._parser.get('catsnap', 'bucket'), 'mypics')
def test_change_config(self, _input, getpass, os): os.environ.__getitem__.return_value = 'mcgee' config = FileConfig() _input.side_effect = [ 'no', 'example.com' ] getpass.getpass.return_value = 'pa55word' config.collect_settings() _input.assert_has_calls([ call("Would you like to print a fake file extension on urls? "), call("Enter the host for your catsnap api: ")]) getpass.getpass.assert_has_calls([ call('Enter your catsnap api key: ')]) eq_(config._parser.get('catsnap', 'api_host'), 'example.com') with open(self.config_tempfile, 'r') as config_file: eq_(config_file.read(), """[catsnap] extension = no api_host = example.com api_key = pa55word """)