Esempio n. 1
0
def test_create_reference_book():
    simple_database = six.u("""
        RFC1918_10 = 10.0.0.0/8      # non-public

        RFC1918_172 = 172.16.0.0/12  # non-public

        RFC1918_192 = 192.168.0.0/16  # non-public

        RFC1918 = RFC1918_10
                  RFC1918_172
                  RFC1918_192
    """)
    defs = _load_test_definitions(simple_database)

    book = capirca.create_reference_book(defs)
    assert book.name == 'capirca'
    assert len(book.addressGroups) == 4
    assert set(g.name for g in book.addressGroups) == {
        'RFC1918', 'RFC1918_10', 'RFC1918_172', 'RFC1918_192'}
    assert not book.interfaceGroups

    book_custom = capirca.create_reference_book(defs, 'testbook')
    assert book_custom.name == 'testbook'
    assert book_custom.addressGroups == book.addressGroups
    assert book_custom.interfaceGroups == book.interfaceGroups
Esempio n. 2
0
def test_create_reference_book():
    simple_database = """
        RFC1918_10 = 10.0.0.0/8      # non-public

        RFC1918_172 = 172.16.0.0/12  # non-public

        RFC1918_192 = 192.168.0.0/16  # non-public

        RFC1918 = RFC1918_10
                  RFC1918_172
                  RFC1918_192
    """
    defs = _load_test_definitions(simple_database)

    book = capirca.create_reference_book(defs)
    assert book.name == "capirca"
    assert len(book.addressGroups) == 4
    assert set(g.name for g in book.addressGroups) == {
        "RFC1918",
        "RFC1918_10",
        "RFC1918_172",
        "RFC1918_192",
    }
    assert not book.interfaceGroups

    book_custom = capirca.create_reference_book(defs, "testbook")
    assert book_custom.name == "testbook"
    assert book_custom.addressGroups == book.addressGroups
    assert book_custom.interfaceGroups == book.interfaceGroups
Esempio n. 3
0
def test_create_reference_book(session, network):
    book = create_reference_book(os.path.join(_this_dir, 'capirca', 'defs'))
    bf_put_reference_book(book)

    getbook = bf_get_reference_book('capirca')
    # TODO: can this just be book equality? Right now, books are implemented
    #  with contents that are lists, and converting to set broke a bunch of
    #  tests that expect those lists to be indexable.
    assert getbook.name == book.name
    assert (set(g.name for g in getbook.addressGroups) == set(
        g.name for g in book.addressGroups))