Coverage for tests/test_apdbSql.py: 43%
Shortcuts 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
Shortcuts 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# This file is part of dax_apdb.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22"""Unit test for Apdb class.
23"""
25from typing import Any
26import unittest
28from lsst.dax.apdb import ApdbConfig, ApdbSqlConfig, ApdbTables
29from lsst.dax.apdb.tests import ApdbTest
30import lsst.utils.tests
33class ApdbSqlTestCase(unittest.TestCase, ApdbTest):
34 """A test case for ApdbSql class
35 """
37 fsrc_requires_id_list = True
38 dia_object_index = "baseline"
40 def make_config(self, **kwargs: Any) -> ApdbConfig:
41 """Make config class instance used in all tests."""
42 kw = {
43 "db_url": "sqlite://",
44 "dia_object_index": self.dia_object_index
45 }
46 kw.update(kwargs)
47 return ApdbSqlConfig(**kw)
49 def n_columns(self, table: ApdbTables) -> int:
50 """Return number of columns for a specified table."""
52 if table is ApdbTables.DiaObject and self.dia_object_index == "last_object_table":
53 # DiaObjectLast is used
54 table = ApdbTables.DiaObjectLast
56 # Some tables add pixelId column to standard schema
57 if table is ApdbTables.DiaObject:
58 return self.n_obj_columns + 1
59 elif table is ApdbTables.DiaObjectLast:
60 return self.n_obj_last_columns + 1
61 elif table is ApdbTables.DiaSource:
62 return self.n_src_columns + 1
63 elif table is ApdbTables.DiaForcedSource:
64 return self.n_fsrc_columns
67class ApdbSqlTestCaseLastObject(ApdbSqlTestCase):
68 """A test case for ApdbSql class using DiaObjectLast table
69 """
71 dia_object_index = "last_object_table"
74class ApdbSqlTestCasePixIdIovIndex(ApdbSqlTestCase):
75 """A test case for ApdbSql class with pix_id_iov indexing
76 """
78 dia_object_index = "pix_id_iov"
81class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
82 pass
85def setup_module(module):
86 lsst.utils.tests.init()
89if __name__ == "__main__": 89 ↛ 90line 89 didn't jump to line 90, because the condition on line 89 was never true
90 lsst.utils.tests.init()
91 unittest.main()