Exemplo n.º 1
0
def test(mock_save, mock_abspath):
    controller = Mock()
    mock_save.return_value = "savepath"

    s = State()
    s.output_file("foo.html")

    bis._show_file_with_state("obj", s, "window", controller)

    assert mock_save.call_count == 1
    assert mock_save.call_args[0] == ("obj", )
    assert mock_save.call_args[1] == {"state": s}

    assert controller.open.call_count == 1
    assert controller.open.call_args[0] == ("file://savepath", )
    assert controller.open.call_args[1] == {"new": 1}

    bis._show_file_with_state("obj", s, "tab", controller)

    assert mock_save.call_count == 2
    assert mock_save.call_args[0] == ("obj", )
    assert mock_save.call_args[1] == {"state": s}

    assert controller.open.call_count == 2
    assert controller.open.call_args[0] == ("file://savepath", )
    assert controller.open.call_args[1] == {"new": 2}
Exemplo n.º 2
0
def test(mock_save, mock_abspath):
    controller = Mock()
    mock_save.return_value = "savepath"

    s = State()
    s.output_file("foo.html")

    bis._show_file_with_state("obj", s, "window", controller)

    assert mock_save.call_count == 1
    assert mock_save.call_args[0] == ("obj",)
    assert mock_save.call_args[1] == {"state": s}

    assert controller.open.call_count == 1
    assert controller.open.call_args[0] == ("file://savepath",)
    assert controller.open.call_args[1] == {"new": 1}

    bis._show_file_with_state("obj", s, "tab", controller)

    assert mock_save.call_count == 2
    assert mock_save.call_args[0] == ("obj",)
    assert mock_save.call_args[1] == {"state": s}

    assert controller.open.call_count == 2
    assert controller.open.call_args[0] == ("file://savepath",)
    assert controller.open.call_args[1] == {"new": 2}