|
6 | 6 | from selenium import webdriver |
7 | 7 |
|
8 | 8 | from neo4j_viz import Node, Relationship, VisualizationGraph |
| 9 | +from neo4j_viz.nvl import NVL |
9 | 10 | from neo4j_viz.options import Layout, Renderer |
10 | 11 |
|
11 | 12 | render_cases = { |
@@ -64,34 +65,6 @@ def test_basic_render(render_option: dict[str, Any], tmp_path: Path) -> None: |
64 | 65 | assert not severe_logs, f"Severe logs found: {severe_logs}, all logs: {logs}" |
65 | 66 |
|
66 | 67 |
|
67 | | -def test_unsupported_field_type() -> None: |
68 | | - with pytest.raises( |
69 | | - ValueError, match="A field of a node object is not supported: Object of type set is not JSON serializable" |
70 | | - ): |
71 | | - nodes = [ |
72 | | - Node( |
73 | | - id="4:d09f48a4-5fca-421d-921d-a30a896c604d:0", caption="Person", properties={"unsupported": {1, 2, 3}} |
74 | | - ), |
75 | | - ] |
76 | | - VG = VisualizationGraph(nodes=nodes, relationships=[]) |
77 | | - VG.render() |
78 | | - |
79 | | - with pytest.raises( |
80 | | - ValueError, |
81 | | - match="A field of a relationship object is not supported: Object of type set is not JSON serializable", |
82 | | - ): |
83 | | - relationships = [ |
84 | | - Relationship( |
85 | | - source="4:d09f48a4-5fca-421d-921d-a30a896c604d:0", |
86 | | - target="4:d09f48a4-5fca-421d-921d-a30a896c604d:6", |
87 | | - caption="BUYS", |
88 | | - properties={"unsupported": {1, 2, 3}}, |
89 | | - ), |
90 | | - ] |
91 | | - VG = VisualizationGraph(nodes=[], relationships=relationships) |
92 | | - VG.render() |
93 | | - |
94 | | - |
95 | 68 | def test_max_allowed_nodes_limit() -> None: |
96 | 69 | nodes = [Node(id=i) for i in range(10_001)] |
97 | 70 | VG = VisualizationGraph(nodes=nodes, relationships=[]) |
@@ -121,3 +94,20 @@ def test_render_warnings() -> None: |
121 | 94 | "relationships. If you need these features, use the canvas renderer by setting the `renderer` parameter", |
122 | 95 | ): |
123 | 96 | VG.render(max_allowed_nodes=20_000, renderer=Renderer.WEB_GL) |
| 97 | + |
| 98 | + |
| 99 | +def test_render_non_json_serializable() -> None: |
| 100 | + import datetime |
| 101 | + |
| 102 | + now = datetime.datetime.now() |
| 103 | + node = Node( |
| 104 | + id=0, |
| 105 | + properties={ |
| 106 | + "non-json-serializable": now, |
| 107 | + }, |
| 108 | + ) |
| 109 | + assert str(now) in NVL._serialize_entity(node) |
| 110 | + |
| 111 | + VG = VisualizationGraph(nodes=[node], relationships=[]) |
| 112 | + # Should not raise an error |
| 113 | + VG.render() |
0 commit comments