subui.validators module¶
-
class
subui.validators.BaseValidator(test_step=None, **kwargs)[source]¶ Bases:
objectBase validator which should be sub-classed to create custom validators.
Variables: BaseValidator.expected_attrs (tuple) – Required attributes for the validator.
_check_improper_configuration()will verify that all of these attributes are defined.Note
Each validator should only define required attributes for itself.
_get_expected_attrs()will automatically return required attributes from all current validator and base classes.Parameters: test_step – subui.step.TestStepinstance which will be used to make assertions on.Note
This parameter is not really required in the
__init__because the same step will be passed intest()however is useful in__init__in case subclass validator needs to apply custom login according to values from thestep.-
expected_attrs= None¶
-
test(test_step)[source]¶ Test the step’s server response by making all the necessary assertions. This method by default saves the
test_stepparameter intostepand validates the validator by using_check_improper_configuration(). All subclass validators should actually implement assertions in this method.Parameters: test_step – Test step
-
-
class
subui.validators.FormInitialDataValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.BaseValidatorValidator checks that form in response has expected data in initial data.
Variables: - initial_data_key (str) – Expected initial data key to be present in form initial data
- expected_initial_data_value – Expected value initial value should be set to
- context_data_form_name (str) – Template context data key for form data
- test_initial_value (bool) – Test if the initial value matched expected value
- test_initial_value_present (bool) – Test if the initial value key is present in initial data
- test_initial_value_not_none (bool) – Test if the initial value is not
None
-
context_data_form_name= u'form'¶
-
expected_attrs= (u'initial_data_key',)¶
-
expected_initial_data_value= None¶
-
initial_data_key= None¶
-
test_initial_value= False¶
-
test_initial_value_not_none= True¶
-
test_initial_value_present= True¶
-
class
subui.validators.HeaderContentTypeValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.HeaderValidatorValidator to check that the expected “Content-Type” header is returned.
-
header_name= u'Content-Type'¶
-
-
class
subui.validators.HeaderLocationValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.HeaderValidatorValidator to check that the redirect “Location” header is returned
-
header_name= u'Location'¶
-
-
class
subui.validators.HeaderValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.BaseValidatorValidator which can check that a particular header is returned and that it is of particular value.
Variables: - HeaderValidator.header_name (str) – Name of the header which must be returned
- expected_header (str) – Expected header value to be returned
- HeaderValidator.test_header_value (bool) – Whether to test the header value or simply check its existence
- test_contains_value – Whether to test if the header value contains another value, or simply check equality to that value
-
expected_attrs= (u'header_name', u'expected_header')¶
-
expected_header= None¶
-
header_name= None¶
-
test(test_step)[source]¶ Test the response returned with :py:attr:header_name header and that its value is equal to :py:attr:expected_header if :py:attr:test_header_value is True. If :py:attr:test_contains_value is True, header value will be tested to contain expected value.
-
test_contains_value= False¶
-
test_header_value= True¶
-
class
subui.validators.RedirectToRouteValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.StatusCodeRedirectValidatorValidator which also checks that the server returns a redirect to an expected Django route.
Variables: expected_route_name (str) – Route name to which the server should redirect to -
expected_attrs= (u'expected_route_name',)¶
-
expected_route_name= None¶
-
test(test_step)[source]¶ Test the response by additionally testing that the response redirects to an expected route as defined by
expected_route_name.
-
-
class
subui.validators.ResponseContentContainsValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.StatusCodeOkValidatorValidator which also checks that returned response content contains expect string.
Variables: expected_content (str) – Expected string in the server response -
expected_attrs= (u'expected_content',)¶
-
expected_content= None¶
-
test(test_step)[source]¶ Test the response by additionally testing that the response context contains expected string as defined by
expected_content.
-
-
class
subui.validators.ResponseContentNotContainsValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.StatusCodeOkValidatorValidator checks that returned response content does not contain unexpected string.
Variables: unexpected_content (str) – Unexpected string in the server response -
expected_attrs= (u'unexpected_content',)¶
-
test(test_step)[source]¶ Test the response by additionally testing that the response context does not contain the unexpected string as defined by
unexpected_content.
-
unexpected_content= None¶
-
-
class
subui.validators.SessionDataValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.BaseValidatorValidator which allows to verify the data in the session based on session key.
Variables: - expected_session_key (str) – Expected session key to be present in session
- expected_session_secondary_keys (list) – List of Expected session key to be present in session
-
expected_attrs= (u'expected_session_key',)¶
-
expected_session_key= None¶
-
expected_session_secondary_keys= []¶
-
class
subui.validators.StatusCodeCreatedValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.StatusCodeValidatorValidator to check that the returned status code is created - 201
-
expected_status_code= 201¶
-
-
class
subui.validators.StatusCodeOkValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.StatusCodeValidatorValidator to check that the returned status code is OK - 200
-
expected_status_code= 200¶
-
-
class
subui.validators.StatusCodeRedirectValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.HeaderLocationValidator,subui.validators.StatusCodeValidatorValidator to check that the server returns a redirect with the “Location” header defined.
-
expected_status_code= 302¶
-
test_header_value= False¶
-
-
class
subui.validators.StatusCodeValidator(test_step=None, **kwargs)[source]¶ Bases:
subui.validators.BaseValidatorValidator which allows to verify the returned server status code such as “OK-200” or “Redirect-302”, etc.
Variables: StatusCodeValidator.expected_status_code (int) – Expected status code to be returned by the server -
expected_attrs= (u'expected_status_code',)¶
-
expected_status_code= None¶
-