def test_new_theme_name_only(project_cli_runner): result = project_cli_runner.invoke( cli, ["dev", "new-theme"], input="Lektor Name Theme\n" "\n" "\n" "\n" "y\n", ) assert "Create Theme?" in result.output assert result.exit_code == 0 path = os.path.join("themes", "lektor-theme-name") assert set(os.listdir(path)) == set( ["example-site", "images", "README.md", "theme.ini"] ) assert set(os.listdir(os.path.join(path, "images"))) == set(["homepage.png"]) assert set(os.listdir(os.path.join(path, "example-site"))) == set( ["lektor-theme-name.lektorproject", "README.md", "themes"] ) try: assert ( os.readlink(os.path.join(path, "example-site/themes/lektor-theme-name")) == "../../../lektor-theme-name" ) except AttributeError: pass theme_inifile = IniFile(os.path.join(path, "theme.ini")) assert theme_inifile["theme.name"] == "Lektor Name Theme" assert theme_inifile["author.email"] == get_default_author_email() assert theme_inifile["author.name"] == get_default_author() with open(os.path.join(path, "README.md")) as f: readme_contents = f.read().strip() assert "Lektor Name Theme" in readme_contents
def test_new_theme_name_only(project_cli_runner): result = project_cli_runner.invoke( cli, ["dev", "new-theme"], input='Lektor Name Theme\n' '\n' '\n' '\n' 'y\n', ) assert "Create Theme?" in result.output assert result.exit_code == 0 path = os.path.join('themes', 'lektor-theme-name') assert set(os.listdir(path)) == set( ['example-site', 'images', 'README.md', 'theme.ini']) assert set(os.listdir(os.path.join(path, 'images'))) == set(['homepage.png']) assert set(os.listdir(os.path.join(path, 'example-site'))) == set( ['lektor-theme-name.lektorproject', 'README.md', 'themes']) try: assert os.readlink(os.path.join( path, 'example-site/themes/lektor-theme-name')) == \ '../../../lektor-theme-name' except AttributeError: pass theme_inifile = IniFile(os.path.join(path, 'theme.ini')) assert theme_inifile['theme.name'] == 'Lektor Name Theme' assert theme_inifile['author.email'] == get_default_author_email() assert theme_inifile['author.name'] == get_default_author() with open(os.path.join(path, 'README.md')) as f: readme_contents = f.read().strip() assert "Lektor Name Theme" in readme_contents
def test_new_plugin_name_only(project_cli_runner): result = project_cli_runner.invoke( cli, ["dev", "new-plugin"], input='Plugin Name\n' '\n' '\n' '\n' 'y\n', ) assert "Create Plugin?" in result.output assert result.exit_code == 0 path = 'packages' assert os.listdir(path) == ['plugin-name'] # setup.py author = get_default_author() author_email = get_default_author_email() setup_expected = textwrap.dedent(""" import ast import io import re from setuptools import setup, find_packages with io.open('README.md', 'rt', encoding="utf8") as f: readme = f.read() _description_re = re.compile(r'description\\s+=\\s+(?P<description>.*)') with open('lektor_plugin_name.py', 'rb') as f: description = str(ast.literal_eval(_description_re.search( f.read().decode('utf-8')).group(1))) setup( author={}'{}', author_email='{}', description=description, keywords='Lektor plugin', license='MIT', long_description=readme, long_description_content_type='text/markdown', name='lektor-plugin-name', packages=find_packages(), py_modules=['lektor_plugin_name'], # url='[link to your repository]', version='0.1', classifiers=[ 'Framework :: Lektor', 'Environment :: Plugins', ], entry_points={{ 'lektor.plugins': [ 'plugin-name = lektor_plugin_name:PluginNamePlugin', ] }} ) """).strip() if PY2: setup_expected = setup_expected.format("u", author, author_email) else: setup_expected = setup_expected.format("", author, author_email) with open(os.path.join(path, 'plugin-name', 'setup.py')) as f: setup_contents = f.read().strip() assert setup_contents == setup_expected
def test_default_author(os_user): from lektor.quickstart import get_default_author assert get_default_author() == "Lektor Test"
def test_default_author(os_user): assert get_default_author() == "Lektor Test"
def test_default_author_from_username(mocker): mocker.patch("getpass.getuser", spec=True, return_value="lektortester") if os.name != "nt": mocker.patch("os.getuid", spec=True, return_value=-1) assert get_default_author() == "lektortester"
def test_default_author_from_pwd(mocker): pw_gecos = "Lektor Tester,,555-1212,," mocker.patch("pwd.getpwuid", spec=True, return_value=struct_passwd(pw_gecos=pw_gecos)) assert get_default_author() == "Lektor Tester"