Coverage for tests/test_dataId.py: 37%

40 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2022-09-11 01:20 -0700

1# 

2# LSST Data Management System 

3# Copyright 2016 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# 

22 

23 

24import unittest 

25 

26import lsst.utils.tests 

27from lsst.daf.persistence import DataId 

28 

29 

30class TestDataId(unittest.TestCase): 

31 """A test case for the DataId class. 

32 """ 

33 

34 def test(self): 

35 dataId = DataId() 

36 self.assertEqual(dataId.tag, set()) 

37 self.assertEqual(dataId, {}) 

38 

39 def testInputDictNoTags(self): 

40 dataId = DataId({'a': 1, 'b': 2}) 

41 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

42 self.assertEqual(dataId.tag, set()) 

43 

44 def testInputDictWithTag(self): 

45 # single tag 

46 dataId = DataId({'a': 1, 'b': 2}, 'foo') 

47 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

48 self.assertEqual(dataId.tag, set(['foo'])) 

49 

50 # tag list 

51 dataId = DataId({'a': 1, 'b': 2}, ['foo', 'bar']) 

52 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

53 self.assertEqual(dataId.tag, set(['foo', 'bar'])) 

54 

55 # tag tuple 

56 dataId = DataId({'a': 1, 'b': 2}, ('foo', 'bar')) 

57 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

58 self.assertEqual(dataId.tag, set(['foo', 'bar'])) 

59 

60 # tag set 

61 dataId = DataId({'a': 1, 'b': 2}, set(['foo', 'bar'])) 

62 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

63 self.assertEqual(dataId.tag, set(['foo', 'bar'])) 

64 

65 def testInputDataId(self): 

66 initDataId = DataId({'a': 1, 'b': 2}, ['foo', 'bar']) 

67 dataId = DataId(initDataId) 

68 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

69 self.assertEqual(dataId.tag, set(['foo', 'bar'])) 

70 

71 dataId = DataId(initDataId, 'baz') 

72 self.assertEqual(dataId, {'a': 1, 'b': 2}) 

73 self.assertEqual(dataId.tag, set(['foo', 'bar', 'baz'])) 

74 

75 

76class MemoryTester(lsst.utils.tests.MemoryTestCase): 

77 pass 

78 

79 

80def setup_module(module): 

81 lsst.utils.tests.init() 

82 

83 

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

85 lsst.utils.tests.init() 

86 unittest.main()