def test_run_usercode_with_loghandler(mocked_run): loghandler = mock.Mock() _run_usercode('py:script.py', ['py:script.py', 'arg1'], _get_apisettings, loghandler) assert mocked_run.called assert loghandler.setLevel.called assert loghandler.setLevel.call_args[0] == (10,)
def test_run_usercode(mocked_run): _run_usercode('py:script.py', ['py:script.py', 'arg1'], _get_apisettings) assert mocked_run.called assert mocked_run.call_args[0][0] == ['py:script.py', 'arg1'] settings = mocked_run.call_args[0][1] assert isinstance(settings, Settings) assert settings['SETTING_TEST'] == 'VAL'
def test_run_usercode(mocked_run): _run_usercode('py:script.py', ['py:script.py', 'arg1'], _get_apisettings) assert mocked_run.called assert mocked_run.call_args[0][0] == ['py:script.py', 'arg1'] settings = mocked_run.call_args[0][1] assert isinstance(settings, Settings) assert settings.get('SETTING_TEST') == 'VAL'
def test_run_usercode_with_loghandler(mocked_run): loghandler = mock.Mock() _run_usercode('py:script.py', ['py:script.py', 'arg1'], _get_apisettings, loghandler) assert mocked_run.called assert loghandler.setLevel.called call_args = loghandler.setLevel.call_args[0] assert len(call_args) == 1 assert call_args[0] == 10
def test_run_usercode_run_exception(mocked_run): mocked_run.side_effect = AttributeError('argA is missing') with pytest.raises(AttributeError): _run_usercode('py:script.py', ['py:script.py'], _get_apisettings) assert mocked_run.called
def test_run_usercode_bad_settings(mocked_run): with pytest.raises(ValueError): _run_usercode('py:script.py', ['py:script.py'], _get_apisettings) assert not mocked_run.called