admin管理员组

文章数量:1125888

I attempted to follow Odoo's Unit Test Documentation, and succeeded to some degree. After creating custom tests for my module, I was able to execute them remotely through the shell.

I would to know if it would be possible to configure it to somehow run the tests of this specific module when we send new code to the odoo.sh instance. How could I do that automatically?

Thank you.

  • Run tests through the terminal
  • Adding different tags to my tests to see if they could be triggered on push

Edit to add more information: I workaround that I attempted to achieve the same result, was to run tests remotely through a controller API call. I setup the controller inside a module on the target instance, and remotely through another instance, I setup a button to call the controller.

When I call the controller (successfully) and set the transient class up to run tests, I used this approach:

    @http.route(_webhook_sale, auth='none', type='http', methods=['POST'], csrf=False)
    def execute_sale_order_uat(self, **post):
        _logger.info("begin execute_sale_order_uat")
        current_company_name = False
        try:
            self.authenticate_token_and_environment(scope='sale_access')
            _logger.info(1)
            TestSaleProjectUAT = TestSaleProject()

            _logger.info(2)
            TestSaleProjectUAT.setUpClass()

            _logger.info(3)
            TestSaleProjectUAT.test_sale_order_with_project_task()

            _logger.info(4)
            TestSaleProjectUAT.test_sol_product_type_update()

            TestSaleProjectUAT.test_cancel_so_linked_to_project()
            TestSaleProjectUAT.test_create_task_from_template_line()
            TestSaleProjectUAT.test_include_archived_projects_in_stat_btn_related_view()

            response_data = {
                'code'   : 200,
                'result' : 'success',
                'message': (_(f"Sale UATs executed successfully on {fields.Datetime.now()}")),
            }

            return Response(
                json.dumps(response_data),
                status=200,
                he

The first time I run, all loggers appear and the tests are run successfully. I confirmed this with loggers inside the test methods inside the class. However, upon running a second time, I get stuck at the setup. Meaning, loggers "1" and "2" occur, but logger "3" does not.

I expected all loggers to properly show up regardless how many times I run the testes remotely through the API call.

I thought that might be caused by me not clearing up the classes at the end of the method. I attemped to do so with this line of code at the end of the test:

    finally:
        TestSaleProjectUAT.tearDownClass()

The same freeze occurs after logger "2".

本文标签: How to run Odoo unit tests remotely on github pushStack Overflow