Coverage for tests/test_dbAuth.py : 44%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#
2# LSST Data Management System
3# Copyright 2008, 2009, 2010 LSST Corporation.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <http://www.lsstcorp.org/LegalNotices/>.
21#
24import unittest
25import os
27import lsst.utils.tests
28from lsst.daf.persistence import DbAuth
29from lsst.pex.policy import Policy
31# Define the root of the tests relative to this file
32ROOT = os.path.abspath(os.path.dirname(__file__))
35class DbAuthTestCase(unittest.TestCase):
36 """A test case for DbAuth."""
38 def setUp(self):
39 pol = Policy(os.path.join(ROOT, "testDbAuth.paf"))
40 DbAuth.setPolicy(pol)
42 def tearDown(self):
43 DbAuth.resetPolicy()
45 def testSetPolicy(self):
46 self.assertTrue(DbAuth.available("lsst-db.ncsa.illinois.edu", "3306"))
47 self.assertEqual(DbAuth.authString("lsst-db.ncsa.illinois.edu", "3306"),
48 "test:globular.test")
49 self.assertEqual(DbAuth.username("lsst-db.ncsa.illinois.edu", "3306"),
50 "test")
51 self.assertEqual(DbAuth.password("lsst-db.ncsa.illinois.edu", "3306"),
52 "globular.test")
53 self.assertTrue(DbAuth.available("lsst-db.ncsa.illinois.edu", "3307"))
54 self.assertEqual(DbAuth.authString("lsst-db.ncsa.illinois.edu", "3307"),
55 "boris:natasha")
56 self.assertEqual(DbAuth.username("lsst-db.ncsa.illinois.edu", "3307"),
57 "boris")
58 self.assertEqual(DbAuth.password("lsst-db.ncsa.illinois.edu", "3307"),
59 "natasha")
60 self.assertTrue(DbAuth.available("lsst9.ncsa.illinois.edu", "3306"))
61 self.assertEqual(DbAuth.authString("lsst9.ncsa.illinois.edu", "3306"),
62 "rocky:squirrel")
63 self.assertEqual(DbAuth.username("lsst9.ncsa.illinois.edu", "3306"),
64 "rocky")
65 self.assertEqual(DbAuth.password("lsst9.ncsa.illinois.edu", "3306"),
66 "squirrel")
69class TestMemory(lsst.utils.tests.MemoryTestCase):
70 pass
73def setup_module(module):
74 lsst.utils.tests.init()
77if __name__ == "__main__": 77 ↛ 78line 77 didn't jump to line 78, because the condition on line 77 was never true
78 lsst.utils.tests.init()
79 unittest.main()