forked from fonsp/Pluto.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.jl
41 lines (33 loc) · 1.5 KB
/
Events.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using Test
import Pluto: Notebook, ServerSession, ClientSession, Cell, load_notebook, load_notebook_nobackup, save_notebook, WorkspaceManager, cutename, numbered_until_new, readwrite, without_pluto_file_extension, PlutoEvent, update_run!
import Random
import Pkg
import UUIDs: UUID
@testset "Private API stability for extended Pluto deployments" begin
events = []
function test_listener(a::PlutoEvent)
@info "this run!"
push!(events, typeof(a))
end
🍭 = ServerSession(; event_listener = test_listener)
🍭.options.evaluation.workspace_use_distributed = false
fakeclient = ClientSession(:fake, nothing)
🍭.connected_clients[fakeclient.id] = fakeclient
notebook = Notebook([
Cell("[1,1,[1]]"),
Cell("Dict(:a => [:b, :c])"),
])
fakeclient.connected_notebook = notebook
update_run!(🍭, notebook, notebook.cells)
WorkspaceManager.unmake_workspace((🍭, notebook))
@test_broken events[1:3] == ["NewNotebookEvent", "OpenNotebookEvent" , "FileSaveEvent"]
# Pluto.CustomLaunchEvent: Gets fired
# Pluto.NewNotebookEvent: Gets fired
# Pluto.OpenNotebookEvent: Gets fired
# Pluto.FileSaveEvent: Gets fired
# Pluto.responses[:juliahub_initiate] = function (🙋::Pluto.ClientRequest) EXTEND end
# Pluto.SessionActions.open(session, string(jhnb_path); notebook_id = UUID(jhub_params[:id]),)
# Pluto.cutename(): returns string
# Pluto.save_notebook(io::IOBuffer, notebook): saves notebook to IO
# Pluto.ServerSession(;options, event_listener)
end