Esempio n. 1
0
    def test_no_config(self, sys):
        sys.argv = ["cmd"]

        with mock.patch(
                'openprocurement.bot.risk_indicators.main.logger.critical'
        ) as log_critical:
            main()

        log_critical.assert_called_once_with("Config is not provided")
Esempio n. 2
0
    def test_incorrect_config(self, sys):
        sys.argv = ["cmd", "openprocurement/bot/risk_indicators/main.py"]

        with mock.patch(
                'openprocurement.bot.risk_indicators.main.logger.critical'
        ) as log_critical:
            main()

        log_critical.assert_any_call("Invalid configuration file")
Esempio n. 3
0
    def test_missed_config(self, sys):
        sys.argv = [
            "cmd", "openprocurement/bot/risk_indicators/config_what.yml"
        ]

        with mock.patch(
                'openprocurement.bot.risk_indicators.main.logger.critical'
        ) as log_critical:
            main()

        log_critical.assert_called_once_with("Invalid configuration file")
Esempio n. 4
0
    def test_run(self, sys):
        sys.argv = [
            "cmd", "openprocurement/bot/risk_indicators/tests/test_config.yaml"
        ]

        with mock.patch(
                'openprocurement.bot.risk_indicators.main.RiskIndicatorBridge'
        ) as bridge:
            bridge.return_value = mock.MagicMock()
            main()

        bridge.assert_called_once()
        bridge.return_value.run.assert_called_once()
Esempio n. 5
0
    def test_run_exception(self, sys):
        sys.argv = [
            "cmd", "openprocurement/bot/risk_indicators/tests/test_config.yaml"
        ]

        with mock.patch(
                'openprocurement.bot.risk_indicators.main.logger.critical'
        ) as log_critical:
            with mock.patch(
                    'openprocurement.bot.risk_indicators.main.RiskIndicatorBridge'
            ) as bridge:
                bridge.side_effect = ValueError(7)
                main()

        bridge.assert_called_once()
        log_critical.assert_any_call("Unhandled exception: 7")