forked from mirrors/thatmattlove-hyperglass
40 lines
1 KiB
Python
40 lines
1 KiB
Python
# Project
|
|
from hyperglass.models.api import Query
|
|
from hyperglass.state import use_state
|
|
from hyperglass.test import initialize_state
|
|
|
|
# Local
|
|
from .._construct import Construct
|
|
|
|
|
|
def test_construct():
|
|
devices = [
|
|
{
|
|
"name": "test1",
|
|
"address": "127.0.0.1",
|
|
"credential": {"username": "", "password": ""},
|
|
"platform": "juniper",
|
|
"attrs": {"source4": "192.0.2.1", "source6": "2001:db8::1"},
|
|
"directives": ["juniper_bgp_route"],
|
|
}
|
|
]
|
|
directives = [
|
|
{
|
|
"juniper_bgp_route": {
|
|
"name": "BGP Route",
|
|
"field": {"description": "test"},
|
|
}
|
|
}
|
|
]
|
|
|
|
initialize_state(params={}, directives=directives, devices=devices)
|
|
|
|
state = use_state()
|
|
|
|
query = Query(
|
|
queryLocation="test1",
|
|
queryTarget="192.0.2.0/24",
|
|
queryType="juniper_bgp_route",
|
|
)
|
|
constructor = Construct(device=state.devices["test1"], query=query)
|
|
assert constructor.target == "192.0.2.0/24"
|