Example #1
0
    def test_failures(self):
        def report_item_generator(i):
            if i == 1:
                raise NodeConnectionException("node", "command", "reason")
            elif i == 2:
                raise LibraryError(
                    ReportItem.error(report_codes.COMMON_ERROR, ),
                    ReportItem.info(report_codes.COMMON_INFO, ))

        assert_raise_library_error(
            lambda: lib_sbd._run_parallel_and_raise_lib_error_on_failure(
                report_item_generator, [([i], {}) for i in range(5)]),
            (Severities.ERROR,
             report_codes.NODE_COMMUNICATION_ERROR_UNABLE_TO_CONNECT, {
                 "node": "node",
                 "command": "command",
                 "reason": "reason"
             }), (Severities.ERROR, report_codes.COMMON_ERROR, {}),
            (Severities.INFO, report_codes.COMMON_INFO, {}))
Example #2
0
    def test_failures(self):
        def report_item_generator(i):
            if i == 1:
                raise NodeConnectionException("node", "command", "reason")
            elif i == 2:
                raise LibraryError(
                    ReportItem.error(
                        report_codes.COMMON_ERROR,
                        "another report"
                    ),
                    ReportItem.info(
                        report_codes.COMMON_INFO,
                        "just info"
                    )
                )

        assert_raise_library_error(
            lambda: lib_sbd._run_parallel_and_raise_lib_error_on_failure(
                report_item_generator,
                [([i], {}) for i in range(5)]
            ),
            (
                Severities.ERROR,
                report_codes.NODE_COMMUNICATION_ERROR_UNABLE_TO_CONNECT,
                {
                    "node": "node",
                    "command": "command",
                    "reason": "reason"
                }
            ),
            (
                Severities.ERROR,
                report_codes.COMMON_ERROR,
                {}
            ),
            (
                Severities.INFO,
                report_codes.COMMON_INFO,
                {}
            )
        )
Example #3
0
 def test_no_report_items(self):
     # test that no exception has been raised
     lib_sbd._run_parallel_and_raise_lib_error_on_failure(
         lambda: [],
         [([], {}) for _ in range(5)]
     )
Example #4
0
 def test_no_report_items(self):
     # test that no exception has been raised
     lib_sbd._run_parallel_and_raise_lib_error_on_failure(
         lambda: [], [([], {}) for _ in range(5)])