Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
lino.api.doctest¶
A selection of names to be used in tested documents.
Functions
|
Replace the callable named name on owner by a wrapper which additionally prints a message on each call. |
|
Parse the given HTML into a BeautifulSoup object. |
|
Checks the result of response which is expected to return a JSON-encoded dictionary with the expected_keys. |
|
|
|
Print an overview description of the specified fields of the specified model. |
|
|
|
|
|
Being authentified as username, perform a web request to uri of the test client. |
|
Recursive utility used by |
|
Remove blank lines from output. |
|
Send a POST with given username, url and data. |
Used to doctest json values and have them be python 2/3 passable. |
|
|
Print the SQL query of the given Django queryset. |
|
|
|
|
Show information about the change watchers that have been installed using |
|
|
Similar to |
Show all the choicelists defined in this application. |
|
|
Print the choices returned via web client. |
|
Like |
|
Show the dashboard of the given user. |
Show the availble display modes per actor. |
|
|
Print a table with the verbose name and the help text of the specified fields in multiple languages. |
|
|
|
Print a list of all fields (in all models) that have the specified type. |
|
Print the main menu for the given user as a reStructuredText-formatted bullet list. |
|
Print the menu path of the given actor or action. |
|
|
|
|
|
|
Print the SQL queries that have been made since last call. |
|
|
Print a summary of the SQL queries that have been made since last call. |
|
|
|
Show the given actions as a table. |
|
Return a list of all translations for the given translatable text. |
|
Print a list of all application menu items and, for items that open a data table, the number of data rows the grid contains. |
|
Iterate over all the atomizers ( |
Classes
|
- 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.
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.
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, **options)¶
Show the dashboard of the given user.
Useful options:
ignore_links=True
For more options, see https://pypi.org/project/html2text/ and https://github.com/Alir3z4/html2text/blob/master/docs/usage.md
Note that this is currently not much used because the result is difficult to maintain. One reason for this is that
naturaltime()
(fromdjango.contrib.humanize.templatetags.humanize
) ignores demo_date and therefore produces results that depend on the current date/time.
Recursive utility used by
show_menu()
.
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.