baseunittest.py¶
Module providing a baseclass for unittests based on ‘TestCase’
-
class
core.unittest.baseunittest.BaseUnitTest(methodName='runTest')[source]¶ Bases:
django.test.testcases.TestCaseBase unit test based on TestCase includes functions for loading json data and automatically filling in forms by initializing forms with instances and retrieving the post_data from them.
-
SMS_STORE¶ - Returns:
- The sms_store which is an array containing all catched SMS messages
-
mail_outbox¶ - Returns:
- The mail outbox which contains all catched outgoing e-mails
-
get(url, status_code=200, check_status_code=True)[source]¶ Shortcut for self.client.get(url) Automatically checks for a proper status_code (200)
-
get_fields_of_form(form)[source]¶ - Returns:
- array of all the fields in the fieldset definition for form param
-
get_post_data(form, prefix='')[source]¶ - Returns:
- a dictionairy with post_data based on what is set as initial on the given form.
-
post_form(url, initial=None, instance=None, extra_data={}, check_status_code=True)[source]¶ Automatic post a form by calling an url and getting the form from the returned response.context
- Args:
- url: the url containing the form
- initial: the initial values to set on the form
- instance: the instance to set on the form.
- extra_data: extra data to inlucde into the post_data
- check_status_code: check the response.code? (default=302)
- Returns:
- the response object
-
get_session_key(value)[source]¶ This method can be used to get the session_key for a healthperson.id
Returns: The session key for the given value.
-
post(url, post_data, status_code=302, check_status_code=True)[source]¶ Shortcut function for posting data
- Args:
- url: the url to post to
- post_data: the post_data to sent
- status_code: the status_code to check for (default=302)
- check_status_code: check the status_code? (default=true)
- Returns:
- the response object
-
get_model_instance_by_class(model_class, to_strip=None)[source]¶ Shortcut function for getting a model instance from the loaded test data based on the model_class.
- Args:
- model_class: the class of the model to search for
- to_strip: optional fields that need to be stripped (currently not used)
- Returns:
- the deserialized instance from the test data
-
login(email, password='remotecare', sms_code='1234', do_sms_code='0')[source]¶ Shortcut function for logging in a user
- Args:
- email: the email address to use
- password: the password to use (default=remotecare)
- sms_code: the sms code to use (default=1234)
- do_sms_code: 0 means do not use
Note
In test modus the SMS_STORE is used to simulate the normal procedure of sms authentication.
- Returns:
- the reponse
-