Source code for odoo_xmlrpc_twisted.support.support_test_activatetoken

"""
Supporting program to test the module :func:`odoo_xmlrpc_twisted.functions.test_activatetoken`.
"""


import sys
import os
import configparser
from datetime import datetime, timedelta

# Add functions directory to path for importing custom modules
sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'functions'))
from test_activatetoken import test_activatetoken
from get_settings_odoo import get_settings_odoo

# Call the function "get_settings_odoo" to get the parameters
# for the logging of the model on the "odoo Webservice API"
result   = get_settings_odoo()
db       = result[0]
uid      = result[1]
password = result[3]
models   = result[4] 


# ------- get parameter from the settings file "parameter_test.ini" 

# Name and full path of the "ini" file.
# As the file "parameter_test.ini" is in the subdirectory "test"
# set the path_name to that directory.
filename  = "parameter_test.ini"
current = os.path.dirname(os.path.realpath(__file__))
parent_directory = os.path.dirname(current)
path_name = parent_directory + '/config'
fullpath  = os.path.join(path_name,filename)

config = configparser.ConfigParser()
config.read(fullpath)

# get the dedicated user_id
custom_user_id = int(config.get('get_settings_customer', 'user_id'))


# set the max duration of the token
# plus 1 day as to be on the safe side ...
duration_date          = datetime.now() + timedelta(days=1)
custom_activate_date = duration_date.strftime("%Y-%m-%d %H:%M:%S")


[docs] def support_test_activatetoken(custom_activate_token): """ Function to test the module "test_activatetoken". As a prerequisite, 'x_activate_complete' must be set to 'False', x_activate_token' must be set and also x_activate_date. Then the function 'test_activatetoken' will be called to see if it works. Result is 'True' or 'False'. """ if custom_activate_token != '': # set the prerequites so that the call of 'test_activatetoken' should work models.execute_kw(db,uid, password, 'res.users', 'write', [[custom_user_id], {'x_activate_token': custom_activate_token, 'x_activate_complete': False, 'x_activate_date': custom_activate_date, }]) # call the function test_activatetoken to see if it works result = test_activatetoken(custom_activate_token) return(result)