Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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())
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
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