Coverage for tests/test_apdbSql.py: 51%

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

39 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 # Some tables add pixelId column to standard schema 

53 if table is ApdbTables.DiaObject: 

54 return self.n_obj_columns + 1 

55 elif table is ApdbTables.DiaObjectLast: 

56 return self.n_obj_last_columns + 1 

57 elif table is ApdbTables.DiaSource: 

58 return self.n_src_columns + 1 

59 elif table is ApdbTables.DiaForcedSource: 

60 return self.n_fsrc_columns 

61 elif table is ApdbTables.SSObject: 

62 return self.n_ssobj_columns 

63 

64 def getDiaObjects_table(self) -> ApdbTables: 

65 """Return type of table returned from getDiaObjects method.""" 

66 return ApdbTables.DiaObject 

67 

68 

69class ApdbSqlTestCaseLastObject(ApdbSqlTestCase): 

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

71 """ 

72 

73 dia_object_index = "last_object_table" 

74 

75 def getDiaObjects_table(self) -> ApdbTables: 

76 """Return type of table returned from getDiaObjects method.""" 

77 return ApdbTables.DiaObjectLast 

78 

79 

80class ApdbSqlTestCasePixIdIovIndex(ApdbSqlTestCase): 

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

82 """ 

83 

84 dia_object_index = "pix_id_iov" 

85 

86 

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

88 pass 

89 

90 

91def setup_module(module): 

92 lsst.utils.tests.init() 

93 

94 

95if __name__ == "__main__": 95 ↛ 96line 95 didn't jump to line 96, because the condition on line 95 was never true

96 lsst.utils.tests.init() 

97 unittest.main()