コード例 #1
0
def test_standalone__port_invalid(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "pants"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(port=8888, debug=True)
コード例 #2
0
def test_standalone__set_host(monkeypatch, mock_App_run, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-o", "127.0.0.2"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(host="127.0.0.2", port=8888, debug=True)
コード例 #3
0
def test_standalone__set_port(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "1337"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(port=1337, debug=True)
コード例 #4
0
def test_standalone__port_invalid(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "pants"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(port=8888, debug=True)
コード例 #5
0
def test_standalone__set_host(monkeypatch, mock_App_run, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-o", "127.0.0.2"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(host="127.0.0.2", port=8888, debug=True)
コード例 #6
0
def test_standalone__set_port(monkeypatch):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "1337"])
    App.run = MagicMock(name='run')

    standalone()

    App.run.assert_called_once_with(port=1337, debug=True)
コード例 #7
0
def test_standalone__port_default(monkeypatch, mock_App_run,
                                  mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py"])

    standalone()

    App.run.assert_called_once_with(host="127.0.0.1", port=8888, debug=True)
コード例 #8
0
def test_standalone__port_default(monkeypatch, app, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py"])
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', FakeApp)

    standalone()

    FakeApp.app.run.assert_called_once_with(host="127.0.0.1", port=8888, debug=True)
コード例 #9
0
def test_standalone__missing_config(monkeypatch, mockfs):
    FakeApp.app = None
    monkeypatch.setattr(sys, 'argv', ["test.py"])
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', FakeApp)

    standalone()

    assert FakeApp.app == None
コード例 #10
0
def test_standalone__port_invalid(monkeypatch, app, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "pants"])

    with pytest.raises(SystemExit):
        standalone()

    assert "invalid int value: 'pants'"
    assert not app.run.called
コード例 #11
0
def test_standalone__port_invalid(monkeypatch, app, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "pants"])

    with pytest.raises(SystemExit):
        standalone()

    assert "invalid int value: 'pants'"
    assert not app.run.called
コード例 #12
0
def test_standalone__port_default(monkeypatch, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py"])
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', FakeApp)

    standalone()

    FakeApp.app.run.assert_called_once_with(host="127.0.0.1",
                                            port=8888,
                                            blocking=True)
コード例 #13
0
def test_standalone__set_port(monkeypatch, app, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "1337"])
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', FakeApp)

    standalone()

    FakeApp.app.run.assert_called_once_with(host="127.0.0.1",
                                            port=1337,
                                            debug=True)
コード例 #14
0
def test_standalone__port_invalid(monkeypatch, mockfs_with_config):
    FakeApp.app = None
    monkeypatch.setattr(sys, 'argv', ["test.py", "-p", "pants"])
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', FakeApp)

    with pytest.raises(SystemExit):
        standalone()

    assert "invalid int value: 'pants'"
    assert FakeApp.app == None
コード例 #15
0
def test_standalone__custom_config__from_argv(
        monkeypatch, mockfs_with_config_and_custom_config):
    monkeypatch.setattr(sys, 'argv',
                        ["test.py", "-c", "/custom/path/to/jasmine.yml"])
    fake_standalone = Mock()
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', fake_standalone)

    standalone()

    fake_standalone.assert_called_once()
    standalone_construction_kwargs = fake_standalone.call_args[1]
    called_with_config = standalone_construction_kwargs[
        'jasmine_config'].yaml_file
    assert called_with_config == "/custom/path/to/jasmine.yml"
コード例 #16
0
def test_standalone__custom_config__when_environment_variable_set(
        monkeypatch, mockfs_with_config_and_custom_config):
    monkeypatch.setattr(sys, 'argv', ["test.py"])
    env_vars = {'JASMINE_CONFIG_PATH': "/custom/path/to/jasmine.yml"}
    monkeypatch.setattr(os, 'environ', env_vars)
    fake_standalone = Mock()
    monkeypatch.setattr(jasmine.entry_points, 'JasmineApp', fake_standalone)

    standalone()

    fake_standalone.assert_called_once()
    standalone_construction_kwargs = fake_standalone.call_args[1]
    called_with_config = standalone_construction_kwargs[
        'jasmine_config'].yaml_file
    assert called_with_config == "/custom/path/to/jasmine.yml"
コード例 #17
0
def test_standalone__missing_config(monkeypatch, mock_App_run, mockfs):
    monkeypatch.setattr(sys, 'argv', ["test.py"])

    standalone()

    assert not App.run.called
コード例 #18
0
def test_standalone__missing_config(monkeypatch, app, mockfs):
    monkeypatch.setattr(sys, 'argv', ["test.py"])

    standalone()

    assert not app.run.called
コード例 #19
0
def test_standalone__port_default(monkeypatch, mock_App_run, mockfs_with_config):
    monkeypatch.setattr(sys, 'argv', ["test.py"])

    standalone()

    App.run.assert_called_once_with(host="127.0.0.1", port=8888, debug=True)