Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.api.doctest

A selection of names to be used in tested documents.

Functions

add_call_logger(owner, name)

Replace the callable named name on owner by a wrapper which additionally prints a message on each call.

beautiful_soup(html)

Parse the given HTML into a BeautifulSoup object.

check_json_result(response[, expected_keys, msg])

Checks the result of response which is expected to return a JSON-encoded dictionary with the expected_keys.

demo_get(username, url_base[, json_fields, ...])

fields_help(model[, fieldnames, columns, all])

Print an overview description of the specified fields of the specified model.

get_fields(model[, fieldnames, columns])

get_json_dict(username, uri[, an])

get_json_soup(username, uri, fieldname, **kwargs)

Being authentified as username, perform a web request to uri of the test client.

menu2rst(mnu[, level])

Recursive utility used by show_menu().

noblanklines(s)

Remove blank lines from output.

post_json_dict(username, url, data, **extra)

Send a POST with given username, url and data.

pprint_json_string(s)

Used to doctest json values and have them be python 2/3 passable.

printsql(qs)

Print the SQL query of the given Django queryset.

py2rst(x[, doctestfmt])

set_log_level(level)

show_change_watchers()

Show information about the change watchers that have been installed using lino.modlib.changes.utils.watch_changes().

show_choicelist(cls)

Similar to rt.show(), but the text is shown in all languages instead of just the current language.

show_choicelists()

Show all the choicelists defined in this application.

show_choices(username, url[, show_count])

Print the choices returned via web client.

show_columns(*args, **kwargs)

Like show_fields() but with columns defaulting to True.

show_dashboard(username[, show_urls])

Show the dashboard of the given user.

show_display_modes()

Show the availble display modes per actor.

show_field_translations(model[, fieldnames, ...])

Print a table with the verbose name and the help text of the specified fields in multiple languages.

show_fields(*args, **kwargs)

show_fields_by_type(fldtype)

Print a list of all fields (in all models) that have the specified type.

show_menu([username, language, stripped, level])

Print the main menu for the given user as a reStructuredText-formatted bullet list.

show_menu_path(spec[, language])

Print the menu path of the given actor or action.

show_model_translations(*models, **kwargs)

show_permissions(*args)

show_quick_search_fields(*args)

show_sql_queries()

Print the SQL queries that have been made since last call.

show_sql_summary(**kwargs)

Print a summary of the SQL queries that have been made since last call.

show_translations(things, fmt[, languages])

show_workflow(actions[, all, language])

Show the given actions as a table.

str2languages(txt)

Return a list of all translations for the given translatable text.

walk_menu_items([username, severe])

Print a list of all application menu items and, for items that open a data table, the number of data rows the grid contains.

walk_store_fields([only_detail_fields])

Iterate over all the atomizers (lino.core.store.StoreField) in this application.

Classes

HttpQuery(username, url_base, json_fields, ...)

class lino.api.doctest.HttpQuery(username, url_base, json_fields, expected_rows, kwargs)

Bases: tuple

expected_rows

Alias for field number 3

json_fields

Alias for field number 2

kwargs

Alias for field number 4

url_base

Alias for field number 1

username

Alias for field number 0

lino.api.doctest.get_json_soup(username, uri, fieldname, **kwargs)

Being authentified as username, perform a web request to uri of the test client.

lino.api.doctest.beautiful_soup(html)

Parse the given HTML into a BeautifulSoup object.

This supports URIs that return a delayed_value.

lino.api.doctest.post_json_dict(username, url, data, **extra)

Send a POST with given username, url and data. The client is expected to respond with a JSON encoded response. Parse the response’s content (which is expected to contain a dict), convert this dict to an AttrDict before returning it.

lino.api.doctest.check_json_result(response, expected_keys=None, msg='')

Checks the result of response which is expected to return a JSON-encoded dictionary with the expected_keys.

lino.api.doctest.show_menu_path(spec, language=None)

Print the menu path of the given actor or action.

Deprecated. You should rather use lino.core.requests.BaseRequest.show_menu_path(), which automatically sets the language of the user and works for any user type.

lino.api.doctest.noblanklines(s)

Remove blank lines from output. This is used to increase readability when some expected output would otherweise contain disturbing <BLANKLINE> that are not relevant to the test itself.

lino.api.doctest.show_choices(username, url, show_count=False)

Print the choices returned via web client.

If show_count is True, show only the number of choices.

lino.api.doctest.show_workflow(actions, all=False, language=None)

Show the given actions as a table. Usage example in Calendar functions in Lino Avanti.

lino.api.doctest.fields_help(model, fieldnames=None, columns=False, all=None)

Print an overview description of the specified fields of the specified model.

If model is an action or table, print the parameter fields of that action or table.

If model is a table and you want the columns instead of the parameter fields, then specify columns=True.

By default this shows only fields that have a help text. If you specify all=True, then also fields that have no help text will be shown.

lino.api.doctest.show_fields_by_type(fldtype)

Print a list of all fields (in all models) that have the specified type.

lino.api.doctest.show_columns(*args, **kwargs)

Like show_fields() but with columns defaulting to True.

lino.api.doctest.walk_menu_items(username=None, severe=True)

Print a list of all application menu items and, for items that open a data table, the number of data rows the grid contains.

lino.api.doctest.show_sql_queries()

Print the SQL queries that have been made since last call.

Usage example: Exploring SQL activity in Lino Noi.

lino.api.doctest.show_sql_summary(**kwargs)

Print a summary of the SQL queries that have been made since last call.

Usage example: Exploring SQL activity in Lino Tera.

lino.api.doctest.add_call_logger(owner, name)

Replace the callable named name on owner by a wrapper which additionally prints a message on each call.

lino.api.doctest.str2languages(txt)

Return a list of all translations for the given translatable text.

lino.api.doctest.show_choicelist(cls)

Similar to rt.show(), but the text is shown in all languages instead of just the current language.

lino.api.doctest.show_choicelists()

Show all the choicelists defined in this application.

lino.api.doctest.show_field_translations(model, fieldnames=None, wrap_width=40, **kwargs)

Print a table with the verbose name and the help text of the specified fields in multiple languages.

If fieldnames is not given, print all fields.

If languages is not given, print all languages defined by the language distribution of this Lino site.

lino.api.doctest.pprint_json_string(s)

Used to doctest json values and have them be python 2/3 passable. :param s: json string

lino.api.doctest.show_dashboard(username, show_urls=False, **options)

Show the dashboard of the given user.

Useful options:

  • show_urls=False

  • ignore_links=True

For more options, see https://pypi.org/project/html2text/ and https://github.com/Alir3z4/html2text/blob/master/docs/usage.md

This is currently not much used because the result is difficult to maintain. One reason for this is that naturaltime() (from django.contrib.humanize.templatetags.humanize) ignores lino.core.site.Site.the_demo_date and therefore produces results that depend on the current date/time.

lino.api.doctest.menu2rst(mnu, level=1)

Recursive utility used by show_menu().

lino.api.doctest.show_menu(username=None, language=None, stripped=True, level=1)

Print the main menu for the given user as a reStructuredText-formatted bullet list.

Username:

the username of the user to select. If this is not specified, anonymous user will be used.

Language:

explicitly select another language than that specified in the requesting user’s language field.

Stripped:

remove lots of blanklines that are necessary for reStructuredText but disturbing in a doctest snippet.

lino.api.doctest.walk_store_fields(only_detail_fields=False)

Iterate over all the atomizers (lino.core.store.StoreField) in this application.

lino.api.doctest.printsql(qs)

Print the SQL query of the given Django queryset. Uses sqlparse for formatting, after removing quotes around field names for readability.

lino.api.doctest.show_change_watchers()

Show information about the change watchers that have been installed using lino.modlib.changes.utils.watch_changes().

lino.api.doctest.show_display_modes()

Show the availble display modes per actor.