Skip to content

Commit 0ea79c4

Browse files
committed
added test that use pycallgraph
1 parent 0be57e3 commit 0ea79c4

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

tests/unit/api/test_Lambda_Run.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from unittest import TestCase
22

33
from pbx_gs_python_utils.utils.Dev import Dev
4+
from pycallgraph import Config, GlobbingFilter, Color
45

56
from osbot.api.Lambda_Handler import Lambda_Handler
67
from osbot.test_helpers.Test_Data import Test_Data
@@ -15,4 +16,35 @@ def test_run(self):
1516
self.handler.run(Test_Data.api_gw_payload_help)
1617

1718
def test_run__no_team(self):
18-
Dev.print(self.handler.run(Test_Data.api_gw_payload_no_team))
19+
Dev.print(self.handler.run(Test_Data.api_gw_payload_no_team))
20+
21+
22+
def test_run_with_trace(self):
23+
def rainbow(node):
24+
return Color.hsv(node.time.fraction * 0.8, 0.4, 0.9)
25+
26+
def greyscale(node):
27+
return Color.hsv(0, 0, node.time.fraction / 2 + 0.4)
28+
29+
def orange_green(node):
30+
return Color( 0.2 + node.time.fraction * 0.8,
31+
0.2 + node.calls.fraction * 0.4 ,
32+
0.2)
33+
34+
from pycallgraph.output import GraphvizOutput
35+
from pycallgraph import PyCallGraph
36+
37+
graphviz = GraphvizOutput()
38+
graphviz.output_file = 'basic.png'
39+
graphviz.edge_color_func = lambda e: Color(0, 0, 0)
40+
#graphviz.node_color_func = rainbow #orange_green # greyscale
41+
42+
config = Config(include_stdlib=True)#max_depth=10)
43+
config.trace_filter = GlobbingFilter(include=['osbot*','pbx*','boto3*'])
44+
45+
with PyCallGraph(output=graphviz, config=config):
46+
try:
47+
self.handler.run(Test_Data.api_gw_payload_help)
48+
except Exception as error:
49+
Dev.pprint(error)
50+

0 commit comments

Comments
 (0)