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_units(self, mock):
test = nb.racks.get(1)
ret = test.units.list()
mock.assert_called_with(
'http://localhost:8000/api/dcim/racks/1/units/',
headers=HEADERS,
verify=True,
)
self.assertTrue(ret)
self.assertTrue(
isinstance(ret[0].device, pynetbox.models.dcim.Devices)
)
""" Represents apps in NetBox.
Calls to attributes are returned as Endpoint objects.
:returns: :py:class:`.Endpoint` matching requested attribute.
:raises: :py:class:`.RequestError`
if requested endpoint doesn't exist.
"""
def __init__(self, api, name):
self.api = api
self.name = name
self._choices = None
self._setmodel()
models = {
"dcim": dcim,
"ipam": ipam,
"circuits": circuits,
"virtualization": virtualization,
"extras": extras
}
def _setmodel(self):
self.model = App.models[self.name] if self.name in App.models else None
def __getstate__(self):
return {
'api': self.api,
'name': self.name,
'_choices': self._choices
}