def configure_ssl(configurator, question, answer): answer = answer.lower() if answer not in ('0', '1', 'y', 'n'): raise ValidationError("Value must be either y/n.") answer = int(answer in ('1', 'y')) if answer: configurator.questions.extend([ Question( 'plume.certificate', 'Please specify the path to the public key', default='/etc/ssl/private/server.pem', required=True, post_ask_question='canari.commands.install_plume:validate_path' ), Question( 'plume.private_key', 'Please specify the path to the private key', default='/etc/ssl/private/server.pem', required=True, post_ask_question='canari.commands.install_plume:validate_path' ), ]) else: configurator.variables['plume.certificate'] = '' configurator.variables['plume.private_key'] = '' return answer
def test_check_name(tmpdir): target_path = tmpdir.strpath + '/collective.todo' question = Question(name="svelte_app_name", question="Name of your Svelte app", default=None) configurator = Configurator( template='bobtemplates.plone:svelte_app', target_directory=target_path, bobconfig={"non_interactive": True}, ) with pytest.raises(ValidationError): svelte_app.check_name(configurator, question, 'My-Svelteapp') with pytest.raises(ValidationError): svelte_app.check_name(configurator, question, 'MySvelteApp') with pytest.raises(ValidationError): svelte_app.check_name(configurator, question, 'mysvelteapp') with pytest.raises(ValidationError): svelte_app.check_name(configurator, question, 'my_svelteapp') with pytest.raises(ValidationError): svelte_app.check_name(configurator, question, 'my_svelte_app') assert svelte_app.check_name(configurator, question, 'my-app') == 'my-app' assert svelte_app.check_name(configurator, question, 'my-svelte-app') == 'my-svelte-app' assert svelte_app.check_name(configurator, question, 'my-cool-svelte-app') == 'my-cool-svelte-app' assert svelte_app.check_name( configurator, question, 'my-cool-svelte-app-one') == 'my-cool-svelte-app-one'
def test_pre_theme_name(): configurator = Configurator( template="bobtemplates.plone:theme_barceloneta", target_directory="collective.theme", ) question = Question("package", "type") theme_barceloneta.pre_theme_name(configurator, question) theme_barceloneta.pre_theme_name(configurator, question)
def test_pre_theme_name(): configurator = Configurator( template='bobtemplates.plone:theme_barceloneta', target_directory='collective.foo', ) question = Question( 'package', 'type', ) theme_barceloneta.pre_theme_name(configurator, question) theme_barceloneta.pre_theme_name(configurator, question)
def test_get_view_template_name(): question = Question(name="view_template_name", question="", default=None) configurator = Configurator( template="bobtemplates.plone:view", target_directory="collective.foo.bar", bobconfig={"non_interactive": True}, variables={ "view_python_class": True, "view_python_class_name": "DemoView" }, ) view.get_view_template_name_from_python_class(configurator, question) assert question.default == 'demo_view'
def test_get_template_name_default(): question = Question(name='view_name', question='', default=None) configurator = Configurator( template='bobtemplates.plone:view', target_directory='collective.foo.bar', bobconfig={ 'non_interactive': True, }, variables={ 'view_template': False, }, ) view.get_template_name_default(configurator, question)
def test_get_view_name_default(): question = Question(name='view_name', question='', default=None) configurator = Configurator( template='bobtemplates.plone:viewlet', target_directory='collective.foo.bar', bobconfig={ 'non_interactive': True, }, variables={ 'viewlet_python_class_name': 'DemoViewlet', }, ) viewlet.get_view_name_from_python_class(configurator, question)
def test_pre_theme_name(tmpdir): base_path = tmpdir.strpath configurator = Configurator( template='bobtemplates.plone:theme', target_directory=os.path.join( base_path, 'collective.foo', ), ) question = Question( 'package', 'type', ) theme.pre_theme_name(configurator, question) theme.pre_theme_name(configurator, question)