File: test_phase.py

package info (click to toggle)
oca-core 11.0.20180730-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 509,684 kB
  • sloc: xml: 258,806; python: 164,081; sql: 217; sh: 92; makefile: 16
file content (64 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

import unittest

from odoo.tests import common


#: Stores state information across multiple test classes
test_state = None

def setUpModule():
    global test_state
    test_state = {}

def tearDownModule():
    global test_state
    test_state = None


class TestPhaseInstall00(unittest.TestCase):
    """
    WARNING: Relies on tests being run in alphabetical order
    """
    @classmethod
    def setUpClass(cls):
        cls.state = None

    def test_00_setup(self):
        type(self).state = 'init'

    @common.at_install(False)
    def test_01_no_install(self):
        type(self).state = 'error'

    def test_02_check(self):
        self.assertEqual(self.state, 'init',
                         "Testcase state should not have been transitioned from 00")


class TestPhaseInstall01(unittest.TestCase):
    at_install = False

    def test_default_norun(self):
        self.fail("An unmarket test in a non-at-install case should not run")

    @common.at_install(True)
    def test_set_run(self):
        test_state['set_at_install'] = True


class TestPhaseInstall02(unittest.TestCase):
    """
    Can't put the check for test_set_run in the same class: if
    @common.at_install does not work for test_set_run, it won't work for
    the other one either. Thus move checking of whether test_set_run has
    correctly run indeed to a separate class.

    Warning: relies on *classes* being run in alphabetical order in test
    modules
    """
    def test_check_state(self):
        self.assertTrue(test_state.get('set_at_install'),
                        "The flag should be set if local overriding of runstate")