diff wsgraph/model.py @ 32:943a4b7097af

fix tests
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 13 Dec 2012 18:59:32 -0800
parents 5f14a4183bf2
children 16673636dcb6
line wrap: on
line diff
--- a/wsgraph/model.py	Thu Dec 13 18:52:04 2012 -0800
+++ b/wsgraph/model.py	Thu Dec 13 18:59:32 2012 -0800
@@ -13,7 +13,7 @@
     """
 
     @abstractmethod
-    def node(self, name, **values):
+    def node(self, name, value=None):
         """
         get or set a node
 
@@ -29,7 +29,7 @@
         """returns a list of all nodes"""
 
     @abstractmethod
-    def edge(self, node1, node2, **values):
+    def edge(self, node1, node2, value=None):
         """
         get or set edge from node1 to node2
         """
@@ -92,10 +92,10 @@
         self._edges = {}
         self._nodes = {}
 
-    def node(self, name, **values):
-        if values:
+    def node(self, name, value=None):
+        if value is not None:
             # setter
-            self._nodes[name] = deepcopy(values)
+            self._nodes[name] = deepcopy(value)
         else:
             # getter
             # TODO: deepcopy
@@ -104,10 +104,12 @@
     def nodes(self):
         return self._nodes.keys()
 
-    def edge(self, node1, node2, **values):
-        if values:
+    def edge(self, node1, node2, value=None):
+        if value is not None:
             # setter
-            self._edges[(node1, node2)] = deepcopy(values)
+            self._edges[(node1, node2)] = deepcopy(value)
+            for node in node1, node2:
+                self._nodes.setdefault(node, {})
         else:
             # getter
             # TODO: deepcopy