lino.api.doctest

A selection of names to be used in tested documents.

(This module's source code is available here.)

Functions

add_call_logger(owner, name)

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

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, ...])

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.

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.

py2rst(x[, doctestfmt])

screenshot(obj, filename, rstname[, username])

Insert a screenshot of the detail window for the given database object.

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_dialog_actions()

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

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

show_fields_by_type(fldtype)

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

show_menu_path(spec[, language])

Print the menu path of the given actor or action.

show_permissions(*args)

show_quick_search_fields(*args)

show_sql_queries()

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

show_sql_summary(**kwargs)

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

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])

Walk through all menu items which run a ShowTable action, showing how many data rows the grid contains.

Classes

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

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

Bases: tuple

property expected_rows

Alias for field number 3

property json_fields

Alias for field number 2

property kwargs

Alias for field number 4

property url_base

Alias for field number 1

property 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.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.screenshot(obj, filename, rstname, username='robin')

Insert a screenshot of the detail window for the given database object.

Usage example in the source code of http://xl.lino-framework.org/specs/holidays.html.

Problems: doesn't seem to wait long enough and therefore produces a white .png file.

How to specify the filename? the current directory when doctest is running is normally the project root, but that's not sure. Best place would be the same directory as the rst file, but how to know that name from within a tested snippet?

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> which are not relevant to the test itself.

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

Print the choices returned via web client.

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.show_fields(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 which 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)

Walk through all menu items which run a ShowTable action, showing how many data rows the grid contains.

lino.api.doctest.show_sql_queries()

Print the SQL queries which 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 which 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.pprint_json_string(s)

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