Exemplo n.º 1
0
def test_validate_billing_data_correct(default_user: User):
    """ Test case to check the validate_billing_data function with correct conditions


    EXPECTED BEHAVIOUR:
        Variables in given User instance match the checked regular expressions and return True
    """
    assert Validator.validate_billing_data(default_user) is True
Exemplo n.º 2
0
def test_validate_billing_data_error(default_user: User):
    """ Test case to check the validate_billing_data function with error conditions


    EXPECTED BEHAVIOUR:
        Variables in given User instance don't match the checked regular expressions and return False
    """

    default_user.dni = '123A'
    assert Validator.validate_billing_data(default_user) is False
Exemplo n.º 3
0
    def save_billing_data(self, full_name: str, dni: str, address: str,
                          mobile_number: str, email: str) -> Response:
        """ Validate the user's billing data and store the data as a User object

        Creates a User object and validates it's data through Validator, if the required
        fields are valid then the user object is stored in the Reservation

        :param full_name: the full name of the user
        :param dni: the DNI (Spanish national identity document) number << VALIDATED >>
        :param address: the address of the user
        :param mobile_number: the user's mobile number << VALIDATED >>
        :param email: the user's email << VALIDATED >>
        :return: Response code to notify the UI of the status of the Reservation object
        """

        response = Response.INVALID_BILLING_DATA
        usr = User(full_name, dni, address, mobile_number, email)
        if Validator.validate_billing_data(usr):
            self._user = copy.deepcopy(usr)
            response = Response.RESERVATION_DATA_UPDATED

        return response