tests/constants.py
def assert_has_node(self: unittest.TestCase, node: BaseEntity, graph: BELGraph, **kwargs):
    """Check if a node with the given properties is contained within a graph."""
    self.assertIsInstance(node, BaseEntity)

    self.assertIn(
        node,
        graph,
        msg='{} not found in graph. Other nodes:\n{}'.format(node.as_bel(), '\n'.join(
            n.as_bel()
            for n in graph
        )),
    )

    if kwargs:
        missing = set(kwargs) - set(graph.nodes[node])
        self.assertFalse(missing, msg="Missing {} in node data".format(', '.join(sorted(missing))))
        self.assertTrue(all(kwarg in graph.nodes[node] for kwarg in kwargs),
                        msg="Missing kwarg in node data")
        self.assertEqual(kwargs, {k: graph.nodes[node][k] for k in kwargs},
                         msg="Wrong values in node data")
Check if a node with the given properties is contained within a graph.
Check if a node with the given properties is contained within a graph.
Check if a node with the given properties is contained within a graph .
def assert_has_node(self: unittest.TestCase, node: BaseEntity, graph: BELGraph, **kwargs):
    self.assertIsInstance(node, BaseEntity)
    self.assertIn(
        node,
        graph,
        msg='{} not found in graph. Other nodes:\n{}'.format(node.as_bel(), '\n'.join(
            n.as_bel()
            for n in graph
        )),
    )
    if kwargs:
        missing = set(kwargs) - set(graph.nodes[node])
        self.assertFalse(missing, msg="Missing {} in node data".format(', '.join(sorted(missing))))
        self.assertTrue(all(kwarg in graph.nodes[node] for kwarg in kwargs),
                        msg="Missing kwarg in node data")
        self.assertEqual(kwargs, {k: graph.nodes[node][k] for k in kwargs},
                         msg="Wrong values in node data")
def assert_has_node ( self : unittest . TestCase , node : BaseEntity , graph : BELGraph , ** kwargs ) : self . assertIsInstance ( node , BaseEntity ) self . assertIn ( node , graph , msg = '{} not found in graph. Other nodes:\n{}' . format ( node . as_bel ( ) , '\n' . join ( n . as_bel ( ) for n in graph ) ) , ) if kwargs : missing = set ( kwargs ) - set ( graph . nodes [ node ] ) self . assertFalse ( missing , msg = "Missing {} in node data" . format ( ', ' . join ( sorted ( missing ) ) ) ) self . assertTrue ( all ( kwarg in graph . nodes [ node ] for kwarg in kwargs ) , msg = "Missing kwarg in node data" ) self . assertEqual ( kwargs , { k : graph . nodes [ node ] [ k ] for k in kwargs } , msg = "Wrong values in node data" )
Check if a node with the given properties is contained within a graph.
Check if a node with the given properties is contained within a graph .
"""Check if a node with the given properties is contained within a graph."""
self
unittest.TestCase
node
BaseEntity
graph
BELGraph