Mercurial > repos > yufei-luo > s_mart
comparison commons/core/sql/test/Test_DbFactory.py @ 6:769e306b7933
Change the repository level.
author | yufei-luo |
---|---|
date | Fri, 18 Jan 2013 04:54:14 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
5:ea3082881bf8 | 6:769e306b7933 |
---|---|
1 # Copyright INRA (Institut National de la Recherche Agronomique) | |
2 # http://www.inra.fr | |
3 # http://urgi.versailles.inra.fr | |
4 # | |
5 # This software is governed by the CeCILL license under French law and | |
6 # abiding by the rules of distribution of free software. You can use, | |
7 # modify and/ or redistribute the software under the terms of the CeCILL | |
8 # license as circulated by CEA, CNRS and INRIA at the following URL | |
9 # "http://www.cecill.info". | |
10 # | |
11 # As a counterpart to the access to the source code and rights to copy, | |
12 # modify and redistribute granted by the license, users are provided only | |
13 # with a limited warranty and the software's author, the holder of the | |
14 # economic rights, and the successive licensors have only limited | |
15 # liability. | |
16 # | |
17 # In this respect, the user's attention is drawn to the risks associated | |
18 # with loading, using, modifying and/or developing or reproducing the | |
19 # software by the user in light of its specific status of free software, | |
20 # that may mean that it is complicated to manipulate, and that also | |
21 # therefore means that it is reserved for developers and experienced | |
22 # professionals having in-depth computer knowledge. Users are therefore | |
23 # encouraged to load and test the software's suitability as regards their | |
24 # requirements in conditions enabling the security of their systems and/or | |
25 # data to be ensured and, more generally, to use and operate it in the | |
26 # same conditions as regards security. | |
27 # | |
28 # The fact that you are presently reading this means that you have had | |
29 # knowledge of the CeCILL license and that you accept its terms. | |
30 | |
31 import os | |
32 import unittest | |
33 from commons.core.sql.DbFactory import DbFactory | |
34 | |
35 class Test_DbFactory( unittest.TestCase ): | |
36 | |
37 def test_createInstance (self): | |
38 dbInstance = DbFactory.createInstance() | |
39 expValue = None | |
40 obsValue = dbInstance | |
41 self.assertNotEquals(expValue, obsValue) | |
42 | |
43 def test_createInstance_with_config (self): | |
44 configFileName = "dummyConfigFileName.cfg" | |
45 configF = open(configFileName,"w") | |
46 configF.write("[repet_env]\n") | |
47 configF.write( "repet_host: %s\n" % ( os.environ["REPET_HOST"] ) ) | |
48 configF.write( "repet_user: %s\n" % ( os.environ["REPET_USER"] ) ) | |
49 configF.write( "repet_pw: %s\n" % ( os.environ["REPET_PW"] ) ) | |
50 configF.write( "repet_db: %s\n" % ( os.environ["REPET_DB"] ) ) | |
51 configF.write( "repet_port: %s\n" % ( os.environ["REPET_PORT"] ) ) | |
52 configF.close() | |
53 | |
54 dbInstance = DbFactory.createInstance(configFileName) | |
55 expValue = None | |
56 obsValue = dbInstance | |
57 self.assertNotEquals(expValue, obsValue) | |
58 os.remove(configFileName) | |
59 | |
60 test_suite = unittest.TestSuite() | |
61 test_suite.addTest( unittest.makeSuite( Test_DbFactory ) ) | |
62 if __name__ == "__main__": | |
63 unittest.TextTestRunner(verbosity=2).run( test_suite ) |