Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_port_collision():
def _raise_os_error():
raise OSError('Address already in use')
with mock.patch('gevent.pywsgi.WSGIServer', new=_define_mock_server(_raise_os_error)):
handle = ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml'))
with pytest.raises(Exception) as exc_info:
host_dagit_ui(handle=handle, host=None, port=2343)
assert 'Another process ' in str(exc_info.value)
def test_unknown_error():
class AnException(Exception):
pass
def _raise_custom_error():
raise AnException('foobar')
with mock.patch('gevent.pywsgi.WSGIServer', new=_define_mock_server(_raise_custom_error)):
handle = ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml'))
with pytest.raises(AnException):
host_dagit_ui(handle=handle, host=None, port=2343)
def test_successful_host_dagit_ui():
with mock.patch('gevent.pywsgi.WSGIServer'):
handle = ExecutionTargetHandle.for_repo_yaml(script_relative_path('./repository.yaml'))
host_dagit_ui(handle=handle, host=None, port=2343)