|
1 | 1 | from odoo.tests import TransactionCase, tagged |
2 | 2 |
|
3 | 3 |
|
4 | | -class TestResCountryCommon(TransactionCase): |
5 | | - @classmethod |
6 | | - def setUpClass(cls): |
7 | | - super().setUpClass() |
8 | | - cls.glorious_arstotzka = cls.env['res.country'].create({ |
| 4 | +@tagged('-at_install', 'post_install') |
| 5 | +class TestResCountryState(TransactionCase): |
| 6 | + def test_find_by_name(self): |
| 7 | + """It should be possible to find a state by its display name |
| 8 | + """ |
| 9 | + glorious_arstotzka = self.env['res.country'].create({ |
9 | 10 | 'name': 'Arstotzka', |
10 | 11 | 'code': 'AA', |
11 | 12 | }) |
12 | | - cls.altan = cls.env['res.country.state'].create({ |
13 | | - 'country_id': cls.glorious_arstotzka.id, |
| 13 | + altan = self.env['res.country.state'].create({ |
| 14 | + 'country_id': glorious_arstotzka.id, |
14 | 15 | 'code': 'AL', |
15 | 16 | 'name': 'Altan', |
16 | 17 | }) |
17 | 18 |
|
18 | | - |
19 | | -@tagged('-at_install', 'post_install') |
20 | | -class TestResCountry(TestResCountryCommon): |
21 | | - def test_name_search(self): |
22 | | - glorious_arstotzka_tuple = (self.glorious_arstotzka.id, self.glorious_arstotzka.display_name) |
23 | | - for (name, op) in [ |
24 | | - ('ARSTOTZKA', '='), |
25 | | - ('arstotzka', '='), |
26 | | - ('ARSTOTZKA', '!='), |
27 | | - ('arstotzka', '!='), |
28 | | - (['ARSTOTZKA'], 'in'), |
29 | | - (['arstotzka'], 'in'), |
30 | | - (['ARSTOTZKA'], 'not in'), |
31 | | - (['arstotzka'], 'not in'), |
32 | | - ]: |
33 | | - with self.subTest((name, op)): |
34 | | - assertFunc = self.assertNotIn if op in ('!=', 'not in') else self.assertEqual |
35 | | - assertFunc( |
36 | | - [glorious_arstotzka_tuple], |
37 | | - self.env['res.country'].name_search(name, operator=op), |
38 | | - f"Failed on operator: '{op}'" |
39 | | - ) |
40 | | - |
41 | | - def test_name_search_code(self): |
42 | | - glorious_arstotzka_tuple = (self.glorious_arstotzka.id, self.glorious_arstotzka.display_name) |
43 | | - res = self.env['res.country'].name_search('aA', operator='=') |
44 | | - self.assertEqual(res, [glorious_arstotzka_tuple]) |
45 | | - |
46 | | - |
47 | | -@tagged('-at_install', 'post_install') |
48 | | -class TestResCountryState(TestResCountryCommon): |
49 | | - def test_find_by_name(self): |
50 | | - """It should be possible to find a state by its display name |
51 | | - """ |
52 | | - glorious_arstotzka = self.glorious_arstotzka |
53 | | - altan = self.altan |
54 | | - |
55 | 19 | for name in [ |
56 | 20 | altan.name, |
57 | 21 | altan.display_name, |
|
0 commit comments