lino.utils.test¶
Defines some TestCase classes that are meant for writing general Python test
cases (not Django test cases, which are defined in
lino.utils.djangotest
).
(This module's source code is available here.)
Classes
|
A |
|
Base class for unit tests that are meant to run directly in a demo project that has been initialized with |
|
Looks for a file "index.rst" in your project_dir and (if it exists) runs doctest on it. |
|
-
class
lino.utils.test.
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
-
property
-
class
lino.utils.test.
CommonTestCase
(methodName='runTest')¶ Bases:
unittest.case.TestCase
A
unittest.TestCase
(not adjango.test.TestCase
) that starts a Django test client on a demo database populated usingprep
.-
create_obj
(model, **values)¶ Create the given database object, run
full_clean()
andsave()
, return the object.This is here for backwards compatibility. New code should use
lino.utils.instantiator.create_row()
instead.
-
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.
-
assertEquivalent
(a, b, report_plain=False)¶ Compares two strings a (expected) and b (got), ignoring whitespace repetitions and writing a logger message in case they are different. For long strings it's then more easy to find the difference.
-
request_PUT
(url, data, **kw)¶ Sends a PUT request using Django's test client, overriding the content_type keyword. This is how ExtJS grids behave by default.
-
-
class
lino.utils.test.
DocTest
(methodName='runTest')¶ Bases:
unittest.case.TestCase
Looks for a file "index.rst" in your project_dir and (if it exists) runs doctest on it.
This is for tests to be run by the Django test runner on a temporary test database.
-
doctest_files
= ['index.rst']¶ The files to be tested.
-
-
class
lino.utils.test.
DemoTestCase
(methodName='runTest')¶ Bases:
lino.utils.pythontest.TestCase
,lino.utils.test.CommonTestCase
Base class for unit tests that are meant to run directly in a demo project that has been initialized with
prep
.It expects the demo database to be initialized, and it should be read-only, i.e. not modify any data.
This is used by the
demotest
command.-
login
(username, pwd)¶ Invoke the
lino.modlib.users.SignIn
action for the given username and password. Unlikedjango.test.Client.force_login()
, this simulates a real login, which later causes Lino to build the JS cache for this user.
-