-
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.
added test_Mermaid__MGraph and couple more misc fixes
added test file with bug test__bugs__Mermaid
- Loading branch information
Showing
8 changed files
with
120 additions
and
45 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
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
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
tests/unit/providers/mermaid/domain/test_Mermaid__Graph.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,31 @@ | ||
import pytest | ||
from unittest import TestCase | ||
from osbot_utils.utils.Objects import __ | ||
from mgraph_ai.providers.mermaid.domain.Mermaid__Graph import Mermaid__Graph | ||
|
||
|
||
class test_Mermaid__MGraph(TestCase): | ||
|
||
def setUp(self): | ||
self.mermaid_graph = Mermaid__Graph() | ||
|
||
def test__init__(self): | ||
with self.mermaid_graph as _: | ||
graph_id = _.graph_id() | ||
assert type(_) is Mermaid__Graph | ||
assert _.obj() == __(model=__(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')) |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
from unittest import TestCase | ||
from mgraph_ai.providers.mermaid.domain.Mermaid__Graph import Mermaid__Graph | ||
from mgraph_ai.mgraph.domain.MGraph__Edge import MGraph__Edge | ||
from mgraph_ai.mgraph.domain.MGraph__Node import MGraph__Node | ||
from mgraph_ai.mgraph.models.Model__MGraph__Edge import Model__MGraph__Edge | ||
from mgraph_ai.mgraph.models.Model__MGraph__Node import Model__MGraph__Node | ||
from mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Edge import Schema__Mermaid__Edge | ||
from mgraph_ai.providers.mermaid.schemas.Schema__Mermaid__Node import Schema__Mermaid__Node | ||
from mgraph_ai.providers.mermaid.utils.Mermaid__Random_Graph import create_test_mermaid_graph | ||
|
||
|
||
class test__bugs__Mermaid(TestCase): | ||
|
||
def test_bug_domain_node_type_mismatch(self): # Bug: Domain node type should be Mermaid__Node but is MGraph__Node | ||
with create_test_mermaid_graph() as graph: | ||
domain_node = graph.graph.nodes()[0] | ||
|
||
# Current incorrect behavior | ||
assert type(domain_node) is MGraph__Node # ✗ Wrong | ||
assert type(domain_node.node) is Model__MGraph__Node # ✗ Wrong | ||
|
||
# Expected behavior (currently fails) | ||
# assert type(domain_node) is Mermaid__Node # ✓ Should be this | ||
# assert type(domain_node.node) is Model__Mermaid__Node # ✓ Should be this | ||
|
||
def test_bug_model_node_type_mismatch(self): # Bug: Model node type should be Model__Mermaid__Node but is Model__MGraph__Node | ||
with create_test_mermaid_graph() as graph: | ||
model_node = graph.graph.model.nodes()[0] | ||
|
||
# Current incorrect behavior | ||
assert type(model_node) is Model__MGraph__Node # ✗ Wrong | ||
assert type(model_node.data) is Schema__Mermaid__Node | ||
|
||
# Expected behavior (currently fails) | ||
# assert type(model_node) is Model__Mermaid__Node # ✓ Should be this | ||
|
||
def test_bug_domain_edge_type_mismatch(self): # Bug: Domain edge type should be Mermaid__Edge but is MGraph__Edge | ||
with create_test_mermaid_graph() as graph: | ||
domain_edge = graph.graph.edges()[0] | ||
|
||
# Current incorrect behavior | ||
assert type(domain_edge) is MGraph__Edge # ✗ Wrong | ||
assert type(domain_edge.edge) is Model__MGraph__Edge # ✗ Wrong | ||
|
||
# Expected behavior (currently fails) | ||
# assert type(domain_edge) is Mermaid__Edge # ✓ Should be this | ||
# assert type(domain_edge.edge) is Model__Mermaid__Edge # ✓ Should be this | ||
# assert domain_edge.graph.edge_model_type == Model__Mermaid__Edge # ✓ Should be this | ||
|
||
def test_bug_model_edge_type_mismatch( | ||
self): # Bug: Model edge type should be Model__Mermaid__Edge but is Model__MGraph__Edge | ||
with create_test_mermaid_graph() as graph: | ||
model_edge = graph.graph.model.edges()[0] | ||
|
||
# Current incorrect behavior | ||
assert type(model_edge) is Model__MGraph__Edge # ✗ Wrong | ||
assert type(model_edge.data) is Schema__Mermaid__Edge | ||
|
||
# Expected behavior (currently fails) | ||
# assert type(model_edge) is Model__Mermaid__Edge # ✓ Should be this | ||
|
||
def test_direct_node_type_mismatch(self): | ||
graph = Mermaid__Graph() | ||
graph_model = graph.model | ||
mermaid_node = Schema__Mermaid__Node() | ||
model_node = graph_model.add_node(mermaid_node) | ||
|
||
# Current behavior (showing type mismatch) | ||
assert isinstance(model_node , Model__MGraph__Node ) # ✗ Wrong: Should be Model__Mermaid__Node | ||
assert isinstance(model_node.data, Schema__Mermaid__Node) # ✓ Correct | ||
|
||
|
||
domain_node = graph.node(mermaid_node.node_config.node_id) # Get node through domain layer | ||
assert isinstance(domain_node, MGraph__Node) # ✗ Wrong: Should be Mermaid__Node |