Example #1
0
    def testMainWithExceptionFromChecks(self, checkAndReportMock):
        class MyException(Exception):
            pass

        checkAndReportMock.side_effect = MyException

        with self.assertRaises(MyException):
            check_model_consistency.main(args=[])
  def testMainWithExceptionFromChecks(self, checkAndReportMock):

    class MyException(Exception):
      pass

    checkAndReportMock.side_effect = MyException

    with self.assertRaises(MyException):
      check_model_consistency.main(args=[])
Example #3
0
    def testMainPassesNonZeroCodeSystemExitFromParseArgs(
            self, checkAndReportMock, parseArgsMock):
        exc = SystemExit(1)
        parseArgsMock.side_effect = exc

        with self.assertRaises(SystemExit) as excCtx:
            check_model_consistency.main(args=[])

        self.assertEqual(excCtx.exception.code, 1)

        self.assertEqual(checkAndReportMock.call_count, 0)
  def testMainPassesNonZeroCodeSystemExitFromParseArgs(self,
                                                       checkAndReportMock,
                                                       parseArgsMock):
    exc = SystemExit(1)
    parseArgsMock.side_effect = exc

    with self.assertRaises(SystemExit) as excCtx:
      check_model_consistency.main(args=[])

    self.assertEqual(excCtx.exception.code, 1)

    self.assertEqual(checkAndReportMock.call_count, 0)
Example #5
0
    def testMainSuppressesZeroCodeSystemExitFromParseArgs(
            self, checkAndReportMock, parseArgsMock):
        parseArgsMock.side_effect = SystemExit(0)

        self.assertEqual(check_model_consistency.main(args=[]), 0)

        self.assertEqual(checkAndReportMock.call_count, 0)
  def testMainSuppressesZeroCodeSystemExitFromParseArgs(self,
                                                        checkAndReportMock,
                                                        parseArgsMock):
    parseArgsMock.side_effect = SystemExit(0)

    self.assertEqual(check_model_consistency.main(args=[]), 0)

    self.assertEqual(checkAndReportMock.call_count, 0)
  def testMainWithErrorFromChecks(self, checkAndReportMock):

    checkAndReportMock.return_value = 1

    self.assertEqual(check_model_consistency.main(args=[]), 1)
  def testMainWithSuccess(self, checkAndReportMock):

    checkAndReportMock.return_value = 0

    self.assertEqual(check_model_consistency.main(args=[]), 0)
Example #9
0
    def testMainWithErrorFromChecks(self, checkAndReportMock):

        checkAndReportMock.return_value = 1

        self.assertEqual(check_model_consistency.main(args=[]), 1)
Example #10
0
    def testMainWithSuccess(self, checkAndReportMock):

        checkAndReportMock.return_value = 0

        self.assertEqual(check_model_consistency.main(args=[]), 0)