Coverage for tests/test_apdbSql.py: 52%
41 statements
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-25 08:49 +0000
« prev ^ index » next coverage.py v6.4.1, created at 2022-06-25 08:49 +0000
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"""
25import os
26import unittest
27from typing import Any
29from lsst.dax.apdb import ApdbConfig, ApdbSqlConfig, ApdbTables
30from lsst.dax.apdb.tests import ApdbTest
31import lsst.utils.tests
33TEST_SCHEMA = os.path.join(os.path.abspath(os.path.dirname(__file__)), "config/schema.yaml")
36class ApdbSqlTestCase(unittest.TestCase, ApdbTest):
37 """A test case for ApdbSql class
38 """
40 fsrc_requires_id_list = True
41 dia_object_index = "baseline"
43 def make_config(self, **kwargs: Any) -> ApdbConfig:
44 """Make config class instance used in all tests."""
45 kw = {
46 "db_url": "sqlite://",
47 "schema_file": TEST_SCHEMA,
48 "dia_object_index": self.dia_object_index
49 }
50 kw.update(kwargs)
51 return ApdbSqlConfig(**kw)
53 def n_columns(self, table: ApdbTables) -> int:
54 """Return number of columns for a specified table."""
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
65 elif table is ApdbTables.SSObject:
66 return self.n_ssobj_columns
68 def getDiaObjects_table(self) -> ApdbTables:
69 """Return type of table returned from getDiaObjects method."""
70 return ApdbTables.DiaObject
73class ApdbSqlTestCaseLastObject(ApdbSqlTestCase):
74 """A test case for ApdbSql class using DiaObjectLast table
75 """
77 dia_object_index = "last_object_table"
79 def getDiaObjects_table(self) -> ApdbTables:
80 """Return type of table returned from getDiaObjects method."""
81 return ApdbTables.DiaObjectLast
84class ApdbSqlTestCasePixIdIovIndex(ApdbSqlTestCase):
85 """A test case for ApdbSql class with pix_id_iov indexing
86 """
88 dia_object_index = "pix_id_iov"
91class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase):
92 pass
95def setup_module(module):
96 lsst.utils.tests.init()
99if __name__ == "__main__": 99 ↛ 100line 99 didn't jump to line 100, because the condition on line 99 was never true
100 lsst.utils.tests.init()
101 unittest.main()