Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] add_pymmmk_istvan #144

Open
wants to merge 13 commits into
base: add_pymmmk
Choose a base branch
from
25 changes: 20 additions & 5 deletions lowkey/MMMKModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,29 @@
# Copyright 2011 by the AToMPM team and licensed under the LGPL
# See COPYING.lesser and README.md in the root of this project for full details

from lowkey.lww.LWWGraph import LWWGraph
from lowkey.lww.LWWMap import LWWMap

__author__ = "Istvan David, Bentley James Oakes"
__author__ = "Istvan David"
__copyright__ = "Copyright 2022, GEODES"
__credits__ = "Eugene Syriani"
__license__ = "GPL-3.0"

class Model(LWWGraph):
def __init__(self):
class Model(LWWMap):
def __init__(self, from_dict : dict = None):
super().__init__()
self.metamodels = []

self.nodes = {}
self.edges = []
self.metamodels = []

if from_dict:
self.nodes = from_dict["nodes"]
self.edges = from_dict["edges"]
self.metamodels = from_dict["metamodels"]

def to_dict(self) -> dict:
return {
"nodes": self.nodes,
"edges": self.edges,
"metamodels": self.metamodels,
}
2 changes: 1 addition & 1 deletion lowkey/MMMKModelEdge.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from lowkey.lww.LWWEdge import LWWEdge

__author__ = "Istvan David, Bentley James Oakes"
__author__ = "Istvan David"
__copyright__ = "Copyright 2022, GEODES"
__credits__ = "Eugene Syriani"
__license__ = "GPL-3.0"
Expand Down
49 changes: 49 additions & 0 deletions lowkey/MMMKModelInterfaceTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python
import unittest

from MMMKModel import Model
from MMMKModelNode import Node
from MMMKModelEdge import Edge

__author__ = "Istvan David"
__copyright__ = "Copyright 2022, GEODES"
__credits__ = "Eugene Syriani"
__license__ = "GPL-3.0"


class MMMKModelLWWTests(unittest.TestCase):

model = None

def setUp(self):
self.model = Model()

def tearDown(self):
self.model = None

def testAddVertices(self):
v1Name = "A"
v2Name = "B"

v1 = Node()
v1.setName(v1Name)
v2 = Node()
v2.setName(v2Name)

self.model.addVertex(v1, 10)
self.assertTrue(self.model.vertexExists(v1))
self.assertEqual(self.model.numberOfVertices(), 1)
v1AdjacencySet = self.model.getAdjacencyListForVertex(v1)
self.assertEqual(len(v1AdjacencySet), 0)

self.model.addVertex(v2, 30)
self.assertTrue(self.model.vertexExists(v1))
self.assertTrue(self.model.vertexExists(v2))
self.assertEqual(self.model.numberOfVertices(), 2)
v1AdjacencySet = self.model.getAdjacencyListForVertex(v1)
v2AdjacencySet = self.model.getAdjacencyListForVertex(v2)
self.assertEqual(len(v1AdjacencySet), 0)
self.assertEqual(len(v2AdjacencySet), 0)

if __name__ == "__main__":
unittest.main()
Loading