Skip to content

Commit

Permalink
test: try testing grapycal
Browse files Browse the repository at this point in the history
  • Loading branch information
eri24816 committed Mar 23, 2024
1 parent 34b1023 commit 028ab4f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
{
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.pytestArgs": [
"backend/test"
]
}
13 changes: 9 additions & 4 deletions backend/src/grapycal/core/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ def __init__(self, port, host, path, workspace_id) -> None:
stdout_helper.enable_proxy(redirect_error=False)


def run(self) -> None:
def run(self, run_runner=True) -> None:
'''
The blocking function that make the workspace start functioning. The main thread will run a background_runner
that runs the background tasks from nodes.
A communication thread will be started to handle the communication between the frontend and the backend.
args:
run_runner: bool
Set to False if you don't want to run the background runner. This is useful for testing.
'''

# Register all the sobject types to the objectsync server, and link some events to the callbacks.
Expand All @@ -111,9 +115,10 @@ def run(self) -> None:
self._load_or_create_workspace()

# Setup is done. Hand the thread over to the background runner.
signal.signal(signal.SIGTERM, lambda sig, frame: self._exit())
self.is_running = True
main_store.runner.run() # this is a blocking call
if run_runner:
signal.signal(signal.SIGTERM, lambda sig, frame: self._exit())
self.is_running = True
main_store.runner.run() # this is a blocking call

'''
Subroutines of run()
Expand Down
19 changes: 19 additions & 0 deletions backend/test/test_a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

from grapycal.core.workspace import Workspace
from grapycal.stores import main_store

def test_node():
workspace = Workspace(port=8766, host="localhost", path="workspace.grapycal", workspace_id=0)
workspace.run(False)

from grapycal_builtin.interaction.execNode import ExecNode
n1 = main_store.main_editor.create_node(ExecNode)
n2 = main_store.main_editor.create_node(ExecNode)
p1 = n1.add_out_port('out')
p2 = n2.add_in_port('in')
e = main_store.main_editor.create_edge(p1, p2)

assert e.tail.get() == p1
assert e.head.get() == p2


2 changes: 0 additions & 2 deletions frontend/src/sobjects/controls/threeControl.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import * as THREE from 'three';
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js';
import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader.js';
import { Control } from './control'
import { ListTopic } from 'objectsync-client'
import { print } from '../../devUtils'
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/sobjects/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,11 +361,6 @@ export class Node extends CompSObject implements IControlHost {
if(this.icon_path.getValue() != ''){
this.setIcon(this.icon_path.getValue())
}
// setTimeout(() => {
// let border = this.htmlItem.getHtmlEl('node-border')
// bloomDiv(border,this.htmlItem.baseElement as HTMLElement)

// }, 0);
}

setIcon(path: string){
Expand Down

0 comments on commit 028ab4f

Please sign in to comment.