Ejemplo n.º 1
0
def test_get_nodes():
    # Create contact plan object
    cp = ContactPlan(1000.1, 42.42)

    # Add nodes and contacts (both resulting in adding nodes to set)
    cp.add_node('testnode1')
    cp.add_contact('testnode2', 'testnode3', 0.0, 1.0)

    # Verify that all nodes were added properly
    assert cp.get_nodes() == ['testnode1', 'testnode2', 'testnode3']
Ejemplo n.º 2
0
def test_clear():
    # Create contact plan object
    cp = ContactPlan(1000.1, 42.42)

    # Add nodes and contacts (both resulting in adding nodes to set)
    cp.add_node('testnode1')
    cp.add_contact('testnode2', 'testnode3', 0.0, 1.0)

    cp.clear()

    assert cp.plan['nodes'] == list()
    assert cp.plan['contacts'] == []
    assert cp.default_delay == 42.42
    assert cp.default_datarate == 1000.1
Ejemplo n.º 3
0
def test_add_node():
    # Create contact plan object
    cp = ContactPlan(1000.1, 42.42)

    # Add node
    cp.add_node('testnode')

    # Check that new node is in node set
    assert 'testnode' in cp.plan['nodes']
    assert len(cp.plan['nodes']) == 1

    # Add node again
    cp.add_node('testnode')

    # Check that new node is in the set only once
    assert 'testnode' in cp.plan['nodes']
    assert len(cp.plan['nodes']) == 1
Ejemplo n.º 4
0
def test_get_outbound_contacts_of_node():
    # Create contact plan object
    cp = ContactPlan(1000.1, 42.42)

    # Add nodes and contacts (both resulting in adding nodes to set)
    cp.add_node('testnode1')
    cp.add_contact('testnode2', 'testnode3', 0.0, 1.0)
    cp.add_contact('testnode2', 'testnode3', 0.0, 1.0)
    cp.add_contact('testnode2', 'testnode3', 10.0, 11.0, bidirectional=False)

    # Verify that all contacts are returned properly
    assert cp.get_outbound_contacts_of_node('testnode1') == []
    assert cp.get_outbound_contacts_of_node('testnode2') == [
        ('testnode2', 'testnode3', 0.0, 1.0, 1000.1, 42.42),
        ('testnode2', 'testnode3', 0.0, 1.0, 1000.1, 42.42),
        ('testnode2', 'testnode3', 10.0, 11.0, 1000.1, 42.42)
    ]
    assert cp.get_outbound_contacts_of_node('testnode3') == [
        ('testnode3', 'testnode2', 0.0, 1.0, 1000.1, 42.42),
        ('testnode3', 'testnode2', 0.0, 1.0, 1000.1, 42.42)
    ]