How to use the pybatfish.client.session.Session function in pybatfish

To help you get started, we’ve selected a few pybatfish examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github batfish / ansible / tests / unit / test_facts.py View on Github external
def test_get_facts_questions():
    """Test that get facts calls the right questions, passing through the right args."""
    bf = Session(load_questions=False)
    nodes = 'foo'
    with patch.object(bf.q,
                      'nodeProperties',
                      create=True) as mock_node, \
            patch.object(bf.q,
                         'interfaceProperties',
                         create=True) as mock_iface, \
            patch.object(bf.q,
                         'bgpPeerConfiguration',
                         create=True) as mock_peers, \
            patch.object(bf.q,
                         'bgpProcessConfiguration',
                         create=True) as mock_proc:
        mock_node.return_value = MockQuestion(MockTableAnswer())
        mock_iface.return_value = MockQuestion(MockTableAnswer())
        mock_proc.return_value = MockQuestion(MockTableAnswer())
github batfish / ansible / tests / unit / test_assertions.py View on Github external
def test_run_assertion():
    """Confirm running passing assertion results in a passing message."""
    bf = Session(load_questions=False)
    assertion = {
        'name': 'assert_name',
        'type': 'assert_no_undefined_references',
    }
    with patch.object(bf.q,
                      'undefinedReferences',
                      create=True) as mock_undef:
        mock_undef.return_value = MockQuestion(MockTableAnswer())
        assert run_assertion(bf, assertion) == ASSERT_PASS_MESSAGE
github batfish / ansible / tests / unit / test_assertions.py View on Github external
def test_run_assertion_fail():
    """Confirm running failing assertion results in a message indicating failure."""
    bf = Session(load_questions=False)
    assertion = {
        'name': 'assert_name',
        'type': 'assert_no_undefined_references',
    }
    with patch.object(bf.q,
                      'undefinedReferences',
                      create=True) as mock_undef:
        mock_undef.return_value = MockQuestion(
            MockTableAnswer(DataFrame.from_records(
                [{'Undef': 'something'}])))
        result = run_assertion(bf, assertion)
    assert ASSERT_PASS_MESSAGE not in result
    assert 'Found undefined reference(s), when none were expected' in result