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

35 statements  

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/>. 

21 

22"""Unit test for Apdb class. 

23""" 

24 

25from typing import Any 

26import unittest 

27 

28from lsst.dax.apdb import ApdbConfig, ApdbSqlConfig, ApdbTables 

29from lsst.dax.apdb.tests import ApdbTest 

30import lsst.utils.tests 

31 

32 

33class ApdbSqlTestCase(unittest.TestCase, ApdbTest): 

34 """A test case for ApdbSql class 

35 """ 

36 

37 fsrc_requires_id_list = True 

38 dia_object_index = "baseline" 

39 

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) 

48 

49 def n_columns(self, table: ApdbTables) -> int: 

50 """Return number of columns for a specified table.""" 

51 

52 if table is ApdbTables.DiaObject and self.dia_object_index == "last_object_table": 

53 # DiaObjectLast is used 

54 table = ApdbTables.DiaObjectLast 

55 

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 

66 

67class ApdbSqlTestCaseLastObject(ApdbSqlTestCase): 

68 """A test case for ApdbSql class using DiaObjectLast table 

69 """ 

70 

71 dia_object_index = "last_object_table" 

72 

73 

74class ApdbSqlTestCasePixIdIovIndex(ApdbSqlTestCase): 

75 """A test case for ApdbSql class with pix_id_iov indexing 

76 """ 

77 

78 dia_object_index = "pix_id_iov" 

79 

80 

81class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

82 pass 

83 

84 

85def setup_module(module): 

86 lsst.utils.tests.init() 

87 

88 

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()