~jfb-tempo-consulting/unifield-wm/sync-env-py3

« back to all changes in this revision

Viewing changes to mkdb.py

  • Committer: Cecile Tonglet
  • Date: 2013-10-17 14:40:19 UTC
  • Revision ID: cto@openerp.com-20131017144019-grjgxx09qz1q311p
[FIX] Version problem with openerplib

Show diffs side-by-side

added added

removed removed

Lines of Context:
70
70
"""
71
71
 
72
72
import sys
 
73
import time
 
74
import pdb
73
75
 
74
76
#Load config file
75
77
import config
81
83
assert coordo_count > 0 if project_count > 0 else coordo_count >= 0, \
82
84
    "Wrong number of Coordinations and Projects!"
83
85
 
84
 
#Load OpenERP Client Library
85
 
import openerplib
86
 
import logging
87
 
 
88
86
#from tests import *
89
87
from tests.openerplib import db
90
88
 
91
89
from scripts.common import *
92
90
 
93
91
#Load tests procedures
 
92
#TODO: use unittest2 instead of unittest to make the command-line arguments
 
93
#      work with python < 2.7
94
94
if sys.version_info >= (2, 7):
95
95
    import unittest
96
96
else:
97
97
    # Needed for setUpClass and skipIf methods
98
98
    import unittest27 as unittest
99
99
 
100
 
try:
101
 
    import ipdb as pdb
102
 
except:
103
 
    import pdb
104
 
 
105
100
skipCreation = False
106
101
skipModules = False
107
102
skipModuleUpdate = False
116
111
skipManualConfig = False
117
112
skipOpenPeriod = False
118
113
 
119
 
_logger = logging.getLogger('mkdb')
 
114
def warn(*messages):
 
115
    sys.stderr.write(" ".join(messages)+"\n")
120
116
 
121
117
# Fake TestCase to enable/disable quickly some tests
122
118
class creation_only(unittest.TestCase):
259
255
                    answer = getattr(self.db.wizard(model, data), button)()
260
256
                model = answer.get('res_model', None)
261
257
            except:
262
 
                _logger.info( "DEBUG: db=%s, model=%s" % (self.db.name, model))
 
258
                warn("DEBUG: db=%s, model=%s" % (self.db.name, model))
263
259
                raise
264
260
 
265
261
    @classmethod
480
476
                'property_account_receivable' : account.search([('code','=','1205')])[0],
481
477
                })
482
478
 
483
 
 
484
479
    @unittest.skipIf(skipOpenPeriod, "Open Period desactivated")
485
480
    def test_92_open_period(self):
486
481
        self.db.connect('admin')
487
 
        import time
488
482
        today = time.strftime('%Y-%m-%d')
489
483
        month = time.strftime('%m')
490
484
        # search current fiscalyear
610
604
 
611
605
class verbose(unittest.TestCase):
612
606
    def test_10_show_hqs(self):
613
 
        _logger.info("---------------------")
 
607
        warn("\n"+"-" * 40)
614
608
        for tc_hq in filter(lambda tc:issubclass(tc, hqn_creation), test_cases):
615
 
            _logger.info( " * %s" % hqn_creation.name_format % (config.prefix, tc_hq.index))
 
609
            warn( " * %s" % hqn_creation.name_format % (config.prefix, tc_hq.index))
616
610
            for tc in filter(lambda tc:issubclass(tc, coordon_creation) \
617
611
                                       and tc.parent is tc_hq, test_cases):
618
 
                _logger.info( "    - %s" % coordon_creation.name_format % (config.prefix, tc.index))
619
 
            _logger.info("---------------------")
 
612
                warn( "    - %s" % coordon_creation.name_format % (config.prefix, tc.index))
 
613
            warn("-" * 40)
620
614
 
621
615
    def test_20_show_coordos(self):
622
 
        print
 
616
        warn("\n"+"-" * 40)
623
617
        for tc_coordo in filter(lambda tc:issubclass(tc, coordon_creation), test_cases):
624
 
            _logger.info( " * %s" % coordon_creation.name_format % (config.prefix, tc_coordo.index))
 
618
            warn( " * %s" % coordon_creation.name_format % (config.prefix, tc_coordo.index))
625
619
            for tc in filter(lambda tc:issubclass(tc, projectn_creation) \
626
620
                                       and tc.parent is tc_coordo, test_cases):
627
 
                _logger.debug( "    - %s" % projectn_creation.name_format % (config.prefix, tc.index))
628
 
            _logger.info("---------------------")
 
621
                warn( "    - %s" % projectn_creation.name_format % (config.prefix, tc.index))
 
622
            warn("-" * 40)
629
623
 
630
624
 
631
625
# Base Install
681
675
 
682
676
if __name__ == '__main__':
683
677
    unittest.main(failfast=True, verbosity=2)
684