Source code for odoo_xmlrpc_twisted.test.test_save_picture

"""
test program for module :func:`odoo_xmlrpc_twisted.functions.save_picture`
based on the "unittest" functionality
"""


import unittest
import os
import sys
import configparser

# Import base test case for automatic cleanup
from odoo_xmlrpc_twisted.test.base_test_case import OdooTestCase

# as this program is in the folder "test",
# import the module to test from the subdirectory "support"
current = os.path.dirname(os.path.realpath(__file__))
parent_directory = os.path.dirname(current)
sys.path.append(parent_directory + '/support')
from support_save_picture import support_save_picture


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

# Name and full path of the "ini" file
filename  = "parameter_test.ini"
# Get the parent directory (repo root) and navigate to config folder
current_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_dir)
config_dir = os.path.join(parent_dir, 'config')
fullpath  = os.path.join(config_dir, filename)

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


#  get the dedicated product id
custom_product_id  = config.get('get_settings_product', 'product_id')
#  get the dedicated name of the picture
custom_image_name  = config.get('get_settings_product', 'image_name')
#  get the perspective of the picture
custom_perspective = config.get('get_settings_product', 'perspective')



[docs] class test_save_picture(OdooTestCase): """ Class for the test cases of the module "save_picture" """
[docs] def test_cases(self): """ test cases of the module "save_picture" """ attachment_id = support_save_picture(custom_product_id, custom_perspective, custom_image_name) # Register created attachment for automatic cleanup if attachment_id: self.addCleanup_attachment(attachment_id) self.assertTrue(attachment_id)
if __name__ == "__main__": unittest.main()