changeset 32:943a4b7097af

fix tests
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 13 Dec 2012 18:59:32 -0800
parents 5f14a4183bf2
children c880cf90f01d
files tests/doctest.txt wsgraph/model.py
diffstat 2 files changed, 11 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/tests/doctest.txt	Thu Dec 13 18:52:04 2012 -0800
+++ b/tests/doctest.txt	Thu Dec 13 18:59:32 2012 -0800
@@ -34,6 +34,6 @@
 
     >>> nodeA = {'hello': "is it me you're looking for?"}
     >>> graph['A'] = nodeA
-    >>> graph.edge('A', 'B', foo='bar')
+    >>> graph.edge('A', 'B', dict(foo='bar'))
     >>> 'A' in graph
     True
--- 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