Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my tests not running on Odoo 10?

I created a simple to-do application with the following structure:

todo_app
    ├── __init__.py
    ├── __manifest__.py
    ├── tests
    │   ├── __init__.py
    │   └── tests_todo.py
    └── todo_model.py

Under the tests folder I have:

  • tests/__init__.py:
# -*- coding: utf-8 -*-
from . import tests_todo
  • tests/tests_todo.py:
# -*- coding: utf-8 -*-
from odoo.tests.common import TransactionCase


class TestTodo(TransactionCase):

    def test_create(self):
        """
        Create a simple Todo
        """
        Todo = self.env['todo.task']
        task = Todo.create({'name': 'Test Task'})
        self.assertEqual(task.is_done, 'foo')

I am deliberately trying to make the tests fail by comparing the boolean task.is_done with the string 'foo' but I don't see anything on the logs:

$ ./odoo/odoo-bin -d todo -u todo_app --test-enable 
2017-03-17 14:25:28,617 6873 INFO ? odoo: Odoo version 10.0
2017-03-17 14:25:28,618 6873 INFO ? odoo: Using configuration file at /home/odoo/.odoorc
2017-03-17 14:25:28,618 6873 INFO ? odoo: addons paths: ['/home/odoo/.local/share/Odoo/addons/10.0', u'/home/odoo/odoo-dev/custom-addons', u'/home/odoo/odoo-dev/odoo/addons', '/home/odoo/odoo-dev/odoo/odoo/addons']
2017-03-17 14:25:28,619 6873 INFO ? odoo: database: default@default:default
2017-03-17 14:25:28,832 6873 INFO ? odoo.service.server: HTTP service (werkzeug) running on 0.0.0.0:8069
2017-03-17 14:25:29,558 6873 INFO todo odoo.modules.loading: loading 1 modules...
2017-03-17 14:25:29,996 6873 INFO todo odoo.modules.loading: 1 modules loaded in 0.44s, 0 queries
2017-03-17 14:25:41,792 6873 INFO todo odoo.modules.loading: loading 13 modules...
2017-03-17 14:25:42,001 6873 INFO todo odoo.modules.registry: module todo_app: creating or updating database tables
2017-03-17 14:25:42,889 6873 INFO todo odoo.modules.loading: 13 modules loaded in 1.10s, 0 queries
2017-03-17 14:25:43,059 6873 WARNING todo odoo.modules.loading: The model todo.task has no access rules, consider adding one. E.g. access_todo_task,access_todo_task,model_todo_task,,1,0,0,0
2017-03-17 14:25:43,625 6873 INFO todo odoo.modules.loading: Modules loaded.
2017-03-17 14:25:43,630 6873 INFO todo odoo.modules.loading: All post-tested in 0.00s, 0 queries

What am I missing?

like image 795
César Avatar asked Mar 17 '17 14:03

César


1 Answers

Try renaming the test module tests/tests_todo.py to tests/test_todo.py. Also, don't forget to update the import in tests/__init__.py to from . import test_todo

This is because Odoo expects the test module names to start with test_ when it searches for tests belonging to a module [reference].

like image 193
Naglis Avatar answered Oct 20 '22 02:10

Naglis