view tests/doctest.txt @ 32:943a4b7097af

fix tests
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 13 Dec 2012 18:59:32 -0800
parents 2fe3933f8eca
children 16673636dcb6
line wrap: on
line source

Test WSGraph
============

The obligatory imports:

    >>> from wsgraph.model import MemoryCache

Make a graph:

    >>> graph = MemoryCache()

The graph starts off empty:

    >>> graph() == {'nodes': {}, 'edges': {}}
    True
    >>> graph.nodes()
    []
    >>> graph.edges()
    []
    >>> graph.node('A') is None
    True
    >>> graph['A'] is None
    True
    >>> graph.edge('A', 'B') is None
    True
    >>> graph[('A', 'B')] is None
    True
    >>> 'A' in graph
    False
    >>> ('A', 'B') in graph
    False

Let's add stuff to it:

    >>> nodeA = {'hello': "is it me you're looking for?"}
    >>> graph['A'] = nodeA
    >>> graph.edge('A', 'B', dict(foo='bar'))
    >>> 'A' in graph
    True