Hide keyboard shortcuts

Hot-keys 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# 

2# LSST Data Management System 

3# Copyright 2008, 2009, 2010 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""" 

24Tests of orca exceptions 

25""" 

26import unittest 

27import lsst.utils.tests 

28 

29from lsst.ctrl.orca.exceptions import MultiIssueConfigurationError 

30 

31 

32def setup_module(module): 

33 lsst.utils.tests.init() 

34 

35 

36class MultiIssueTestCase(lsst.utils.tests.TestCase): 

37 unspecified = "Unspecified configuration problems encountered" 

38 generic = "Multiple configuration problems encountered" 

39 

40 def setUp(self): 

41 pass 

42 

43 def tearDown(self): 

44 pass 

45 

46 def testNoProb(self): 

47 err = MultiIssueConfigurationError() 

48 self.assertFalse(err.hasProblems()) 

49 self.assertEqual(str(err), self.unspecified) 

50 

51 probs = err.getProblems() 

52 self.assertEqual(len(probs), 0) 

53 

54 def testOneProb(self): 

55 msg = "first problem" 

56 err = MultiIssueConfigurationError(problem=msg) 

57 self.assertEqual(str(err), msg) 

58 

59 probs = err.getProblems() 

60 self.assertEqual(len(probs), 1) 

61 self.assertEqual(probs[0], msg) 

62 

63 def testTwoProbs(self): 

64 msg = "first problem" 

65 err = MultiIssueConfigurationError(problem=msg) 

66 self.assertEqual(str(err), msg) 

67 msg2 = "second problem" 

68 err.addProblem(msg2) 

69 self.assertEqual(str(err), self.generic) 

70 

71 probs = err.getProblems() 

72 self.assertEqual(len(probs), 2) 

73 self.assertEqual(probs[0], msg) 

74 self.assertEqual(probs[1], msg2) 

75 

76 def testGenericMsg(self): 

77 msg = "problems encountered while checking configuration" 

78 err = MultiIssueConfigurationError(msg) 

79 self.assertEqual(str(err), self.unspecified) 

80 

81 msg1 = "first problem" 

82 err.addProblem(msg1) 

83 self.assertEqual(str(err), msg1) 

84 

85 err.addProblem("2nd problem") 

86 self.assertEqual(str(err), msg) 

87 

88 

89class ExceptionsMemoryTester(lsst.utils.tests.MemoryTestCase): 

90 pass 

91 

92 

93__all__ = "MultiIssueTestCase".split() 

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