コード例 #1
0
ファイル: test_structure.py プロジェクト: mulkieran/pyblk
        def test_holders(self, device):
            """
            Verify holders graph has same number of nodes as traversal.

            Traversal may contain duplicates, while graph should eliminate
            duplicates during its construction. Traversal results does not
            include origin device, graph nodes do.
            """
            holders = list(pyblk.holders(CONTEXT, device))
            graph = pyblk.SysfsTraversal.holders(CONTEXT, device)
            graph_len = len(graph)
            assert len(set(holders)) == (graph_len - 1 if graph_len else 0)
コード例 #2
0
ファイル: test_traversal.py プロジェクト: mulkieran/pyblk
        def test_inverse(self, device, recursive):
            """
            Verify that a round-trip traversal will encounter the original
            device.

            :param device: the device to test
            :param bool recursive: if True, test recursive relationship

            If recursive is True, test ancestor/descendant relationship.
            If recursive is False, tests parent/child relationship.
            """
            # pylint: disable=too-many-function-args
            slaves = list(pyblk.slaves(CONTEXT, device, recursive))
            for slave in slaves:
                assert device in list(
                   pyblk.holders(CONTEXT, slave, recursive)
                )

            holders = list(pyblk.holders(CONTEXT, device, recursive))
            for holder in holders:
                assert device in list(
                   pyblk.slaves(CONTEXT, holder, recursive)
                )
コード例 #3
0
ファイル: _constants.py プロジェクト: mulkieran/pyblk
    .. moduleauthor:: mulhern <*****@*****.**>
"""


from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import pyudev

import pyblk

CONTEXT = pyudev.Context()
DEVICES = CONTEXT.list_devices()

# pylint: disable=too-many-function-args

SLAVES = [d for d in DEVICES if list(pyblk.slaves(CONTEXT, d, False))]

HOLDERS = [d for d in DEVICES if list(pyblk.holders(CONTEXT, d, False))]

BOTHS = list(set(SLAVES).intersection(set(HOLDERS)))

EITHERS = list(set(SLAVES).union(set(HOLDERS)))

GRAPH = pyblk.GenerateGraph.get_graph(CONTEXT, "graph")

DECORATED = pyblk.GenerateGraph.get_graph(CONTEXT, "graph")
pyblk.GenerateGraph.decorate_graph(CONTEXT, DECORATED)
コード例 #4
0
ファイル: test_traversal.py プロジェクト: mulkieran/pyblk
 def test_holders(self, device):
     """
     Verify holders do not contain originating device.
     """
     assert device not in pyblk.holders(CONTEXT, device)