def test_net_closest_parent(client, site):
    site_id = site['id']
    c = client

    parent = Network(client=c, site_id=site_id, cidr='8.8.8.0/24')
    assert parent.ensure()

    child = Network(client=c, site_id=site_id, cidr='8.8.8.8/32')
    assert child.closest_parent() == parent

    orphan = Network(client=c, site_id=site_id, cidr='1.1.1.1/32')
    assert not orphan.closest_parent()
    assert orphan.closest_parent() == {}
Test that Network.closest_parent returns instance of Network or dict
dataset/ETHPy150Open dropbox/pynsot/tests/test_models.py/test_net_closest_parent