Skip to content

Commit

Permalink
minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DinisCruz committed Feb 5, 2025
1 parent 4e382a4 commit 43837bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 15 deletions.
3 changes: 1 addition & 2 deletions mgraph_db/mgraph/actions/MGraph__Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

class MGraph__Export(Type_Safe):
graph : Domain__MGraph__Graph
dot_config : MGraph__Export__Dot__Config

def data(self): # Access to graph data
return MGraph__Data(graph=self.graph)

def export_dot(self):
return MGraph__Export__Dot(graph=self.graph, config=self.dot_config)
return MGraph__Export__Dot(graph=self.graph)

def to__mgraph_json(self): # Export full graph data
return self.graph.model.data.json()
Expand Down
3 changes: 0 additions & 3 deletions mgraph_db/mgraph/actions/MGraph__Screenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ def dot(self):
png_bytes = self.dot_to_png(dot_code)
return png_bytes

def dot_config(self):
return self.export().dot_config

def dot__just_ids(self):
dot_code = self.export().to__dot()
png_bytes = self.dot_to_png(dot_code)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ def test_custom_config(self):

def test__mgraph_export(self):
with self.simple_graph.export() as _:
assert _.to__dot_types () == self.exporter.to_types_view ()
assert _.to__dot_schema() == self.exporter.to_schema_view()
assert _.to__dot () == self.exporter.process_graph()
assert _.to__dot () == self.exporter.process_graph ()
assert _.to__dot_types () == self.exporter.to_types_view () # this has to go last, because this test does: self.config.show_edge_ids = False

def test_node_attribute_formatting(self): # Test the new node attribute formatting methods
node_id = self.nodes_ids[0]
Expand Down
7 changes: 1 addition & 6 deletions tests/unit/mgraph/actions/test_MGraph__Export.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ def test__init__(self):
mgraph = MGraph()
with mgraph.export() as _:
assert type(_) is MGraph__Export
assert _.obj() == __( graph = mgraph.graph.obj() ,
dot_config = __(show_value = False ,
show_edge_ids = True ,
font_name = 'Arial',
font_size = 10 ,
rank_sep = 0.8 ))
assert _.obj() == __( graph = mgraph.graph.obj())

def test_to__mgraph_json(self): # Test full graph export
empty_graph = MGraph()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import pytest
from unittest import TestCase
from mgraph_db.mgraph.actions.MGraph__Export import MGraph__Export
from mgraph_db.mgraph.actions.exporters.MGraph__Export__Dot import MGraph__Export__Dot
from mgraph_db.mgraph.domain.Domain__MGraph__Node import Domain__MGraph__Node
from mgraph_db.mgraph.models.Model__MGraph__Graph import Model__MGraph__Graph
from mgraph_db.mgraph.models.Model__MGraph__Node import Model__MGraph__Node
from mgraph_db.mgraph.schemas.Schema__MGraph__Graph import Schema__MGraph__Graph
from mgraph_db.providers.time_series.MGraph__Time_Series import MGraph__Time_Series
from mgraph_db.providers.time_series.actions.MGraph__Time_Series__Edit import MGraph__Time_Series__Edit
from mgraph_db.providers.time_series.actions.MGraph__Time_Series__Screenshot import MGraph__Time_Series__Screenshot
from mgraph_db.providers.time_series.schemas.Schema__MGraph__Node__Value__Int import Schema__MGraph__Node__Value__Int
from mgraph_db.providers.time_series.schemas.Schema__MGraph__Node__Value__Int__Data import Schema__MGraph__Node__Value__Int__Data
from osbot_utils.utils.Dev import pprint
from osbot_utils.utils.Dev import pprint
from osbot_utils.utils.Env import load_dotenv
from osbot_utils.utils.Files import file_exists, file_delete
from osbot_utils.utils.Objects import __, type_full_name
Expand All @@ -35,6 +38,10 @@ def tearDown(self):
# _.print()
if self.screenshot_create:
with self.graph.screenshot(target_file=self.screenshot_file) as _:
assert type(_) is MGraph__Time_Series__Screenshot
assert type(_.export().export_dot()) is MGraph__Export__Dot
assert _.export_class is MGraph__Export

#_.dot__just_types()
#_.dot__just_values()
_.dot__just_ids()
Expand Down Expand Up @@ -127,7 +134,7 @@ def test__get_or_create_int_value(self):
def test_create_time_point(self): # Test creating time point
time_point = self.graph_edit.create_time_point(year=2024, month=2, day=14, hour=15, minute=30)

pprint(time_point.json())
#pprint(time_point.json())
return
assert type(time_point.node.data) is Schema__MGraph__Node__Time_Point # Check time point creation
assert is_obj_id(time_point.node_id)
Expand Down

0 comments on commit 43837bd

Please sign in to comment.