websauna.tests.cookiecutter.scaffold module

Scaffold test utility functions.

websauna.tests.cookiecutter.scaffold.app_scaffold(request, cookiecutter_config)[source]

py.test fixture to create app scaffold.

Create application and virtualenv for it. Run setup.py.

Return type

str

Returns

Path to a temporary folder. In this folder there is venv folder and myapp folder.

websauna.tests.cookiecutter.scaffold.cookiecutter_config(tmpdir_factory)[source]

py.test fixture to generate a tmp config file for cookiecutter.

Return type

str

Returns

Path to cookiecutter config file.

websauna.tests.cookiecutter.scaffold.create_psq_db(request, dbname, dsn='')[source]

py.test fixture to createdb and destroy postgresql database on demand.

websauna.tests.cookiecutter.scaffold.execute_command(cmdline, folder, timeout=5.0)[source]

Run a command in a specific folder.

websauna.tests.cookiecutter.scaffold.execute_venv_command(cmdline, cwd, timeout=15.0, wait_and_see=None, assert_exit=0, cd_folder=None)[source]

Run a command in a specific folder using virtualenv created there.

Assume virtualenv is under venv folder.

Parameters
  • cwd – Base folder.

  • timeout – Command timeout.

  • wait_and_see – Wait this many seconds to see if app starts up.

  • assert_exit – Assume exit code is this

  • cd_folder – cd to this folder before executing the command (relative to folder)

Returns

tuple (exit code, stdout, stderr)

websauna.tests.cookiecutter.scaffold.insert_content_after_line(path, content, marker)[source]

Add piece to text to a text file after a line having a marker string on it.

websauna.tests.cookiecutter.scaffold.preload_wheelhouse(folder)[source]

Speed up tests by loading Python packages from primed cache.

Use create_wheelhouse.bash to prime the cache.

Parameters

folder (str) – Temporary virtualenv installation

websauna.tests.cookiecutter.scaffold.print_subprocess_fail(worker, cmdline)[source]
websauna.tests.cookiecutter.scaffold.replace_file(path, content)[source]

A context manager to temporary swap the content of a file.

Parameters
  • path (str) – Path to the file

  • content (str) – New content as a text

websauna.tests.cookiecutter.scaffold.start_ws_pserve(config, cwd, wait_and_see=5.0, cd_folder='')[source]

Simulate starting ws-pserve command from the command line inside the virtualenv.

Parameters
  • config (str) – Configuration.

  • cwd (str) – Set current working directory

  • wait_and_see (float) – Seconds to see if the server comes up

  • cd_folder – cd to this folder before executing the command (relative to folder)