-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
more misc fixes
- Loading branch information
Showing
15 changed files
with
193 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
mgraph_ai/providers/mermaid/schemas/Schema__Mermaid__Node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from typing import Type | ||
from osbot_utils.helpers.Safe_Id import Safe_Id | ||
from mgraph_ai.mgraph.schemas.Schema__MGraph__Node import Schema__MGraph__Node | ||
from typing import Type | ||
from mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node__Config import Schema__Mermaid__Node__Config | ||
from osbot_utils.helpers.Safe_Id import Safe_Id | ||
from mgraph_ai.mgraph.schemas.Schema__MGraph__Node import Schema__MGraph__Node | ||
|
||
class Schema__Mermaid__Node(Schema__MGraph__Node): | ||
key : Safe_Id | ||
label : str | ||
node_type: Type['Schema__Mermaid__Node'] | ||
key : Safe_Id | ||
label : str | ||
node_config: Schema__Mermaid__Node__Config | ||
node_type : Type['Schema__Mermaid__Node'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
126 changes: 126 additions & 0 deletions
126
tests/unit/providers/mermaid/domain/test_Mermaid_Node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
from unittest import TestCase | ||
from osbot_utils.utils.Objects import __ | ||
from mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node import Schema__Mermaid__Node | ||
from mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node__Shape import Schema__Mermaid__Node__Shape | ||
from mgraph_ai.providers.mermaid.domain.Mermaid import Mermaid | ||
from mgraph_ai.providers.mermaid.domain.Mermaid__Node import Mermaid__Node | ||
|
||
|
||
class test_Mermaid_Node(TestCase): | ||
|
||
def setUp(self): | ||
self.mermaid_node = Mermaid__Node() | ||
self.mermaid_node_id = self.mermaid_node.node_id() | ||
self.mermaid_node_data = self.mermaid_node.node.data | ||
self.mermaid_node_config = self.mermaid_node.node.data.node_config | ||
|
||
def test__init__(self): | ||
with self.mermaid_node as _: | ||
node_id = _.node_id() | ||
node_key = _.node_key() | ||
graph_id = _.graph_id() | ||
|
||
assert type(_) is Mermaid__Node | ||
assert _.obj() == __(node=__(data=__(key = node_key , | ||
label = node_key , | ||
node_config =__(node_shape = 'default', | ||
show_label = True , | ||
wrap_with_quotes = True , | ||
markdown = False , | ||
node_id = node_id , | ||
value_type = None ), | ||
node_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node.Schema__Mermaid__Node', | ||
attributes = __(), | ||
value=None)), | ||
graph=__(data=__(default_types = __(edge_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Edge.Schema__Mermaid__Edge', | ||
edge_config_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Edge__Config.Schema__Mermaid__Edge__Config', | ||
graph_config_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Graph__Config.Schema__Mermaid__Graph__Config', | ||
node_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node.Schema__Mermaid__Node', | ||
node_config_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node__Config.Schema__Mermaid__Node__Config', | ||
attribute_type = 'mgraph_ai.mgraph.schemas.Schema__MGraph__Attribute.Schema__MGraph__Attribute'), | ||
edges = __(), | ||
graph_config = __(allow_circle_edges = False , | ||
allow_duplicate_edges = False , | ||
graph_title = '' , | ||
graph_id = graph_id ), | ||
graph_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Graph.Schema__Mermaid__Graph', | ||
mermaid_code = [], | ||
nodes = __()), | ||
node_model_type = 'mgraph_ai.providers.mermaid.models.Model__Mermaid__Node.Model__Mermaid__Node', | ||
edge_model_type = 'mgraph_ai.providers.mermaid.models.Model__Mermaid__Edge.Model__Mermaid__Edge')) | ||
|
||
def test_shape(self): | ||
assert self.mermaid_node.shape(Schema__Mermaid__Node__Shape.round_edges).config().node_shape == Schema__Mermaid__Node__Shape.round_edges | ||
assert self.mermaid_node.shape(Schema__Mermaid__Node__Shape.rhombus ).config().node_shape == Schema__Mermaid__Node__Shape.rhombus | ||
assert self.mermaid_node.shape(Schema__Mermaid__Node__Shape.default ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape('round_edges' ).config().node_shape == Schema__Mermaid__Node__Shape.round_edges | ||
assert self.mermaid_node.shape('rhombus' ).config().node_shape == Schema__Mermaid__Node__Shape.rhombus | ||
assert self.mermaid_node.shape('default' ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape('aaaa' ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape(' ' ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape('' ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape(None ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape( ).config().node_shape == Schema__Mermaid__Node__Shape.default | ||
|
||
def test_shape__shape_name(self): | ||
assert self.mermaid_node.shape_hexagon() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.hexagon | ||
assert self.mermaid_node.shape_parallelogram() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.parallelogram | ||
assert self.mermaid_node.shape_parallelogram_alt() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.parallelogram_alt | ||
assert self.mermaid_node.shape_rectangle() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.rectangle | ||
assert self.mermaid_node.shape_trapezoid() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.trapezoid | ||
assert self.mermaid_node.shape_trapezoid_alt() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.trapezoid_alt | ||
assert self.mermaid_node.shape_default() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.default | ||
assert self.mermaid_node.shape_round_edges() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.round_edges | ||
assert self.mermaid_node.shape_rhombus() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.rhombus | ||
assert self.mermaid_node.shape_circle() is self.mermaid_node; assert self.mermaid_node.config().node_shape == Schema__Mermaid__Node__Shape.circle | ||
|
||
|
||
def test_wrap_with_quotes(self): | ||
assert self.mermaid_node_config.wrap_with_quotes == True | ||
assert self.mermaid_node.wrap_with_quotes( ).config().wrap_with_quotes == True | ||
assert self.mermaid_node.wrap_with_quotes(False).config().wrap_with_quotes == False | ||
assert self.mermaid_node.wrap_with_quotes(True ).config().wrap_with_quotes == True | ||
|
||
|
||
def test__config__wrap_with_quotes(self): | ||
data_obj = self.mermaid_node_data.set_key('id').set_label('id') | ||
node_obj = self.mermaid_node.wrap_with_quotes() | ||
assert type(data_obj ) is Schema__Mermaid__Node | ||
assert type(node_obj ) is Mermaid__Node | ||
|
||
assert node_obj.config().wrap_with_quotes == True | ||
assert data_obj.key == 'id' | ||
|
||
assert data_obj.obj() == __(key = 'id', | ||
label = 'id', | ||
node_config = __(node_shape = 'default', | ||
show_label = True, | ||
wrap_with_quotes = True, | ||
markdown = False, | ||
node_id = self.mermaid_node_id, | ||
value_type = None ), | ||
node_type = 'mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node.Schema__Mermaid__Node', | ||
attributes = __(), | ||
value=None) | ||
assert Schema__Mermaid__Node.from_json(data_obj.json()).json() == data_obj.json() | ||
#pprint(node_obj.json()) | ||
|
||
return # todo: wire up the methods below | ||
with Mermaid() as _: | ||
_.add_node(key='id') | ||
assert _.code() == 'graph LR\n id["id"]\n' | ||
pass | ||
#pprint(Mermaid().json()) | ||
|
||
#return | ||
with Mermaid() as _: | ||
_.add_node(key='id').wrap_with_quotes(False) | ||
assert _.code() == 'graph LR\n id[id]\n' | ||
|
||
mermaid = Mermaid() | ||
new_node = mermaid.add_node(key='id') | ||
new_node.wrap_with_quotes(False) | ||
assert type(new_node) == Mermaid__Node | ||
assert new_node.attributes == {} | ||
assert mermaid.code() == 'graph LR\n id[id]\n' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 13 additions & 13 deletions
26
tests/unit/providers/mermaid/schemas/test_Schema__Mermaid__Node.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.