How to use the pynetbox.core.response function in pynetbox

To help you get started, we’ve selected a few pynetbox examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github digitalocean / pynetbox / tests / test_dcim.py View on Github external
nb = api.dcim

HEADERS = {
    'accept': 'application/json;',
}

AUTH_HEADERS = {
    'accept': 'application/json;',
    'authorization': 'Token None',
}


class Generic(object):
    class Tests(unittest.TestCase):
        name = ''
        ret = pynetbox.core.response.Record
        app = 'dcim'

        def test_get_all(self):
            with patch(
                'pynetbox.core.query.requests.sessions.Session.get',
                return_value=Response(fixture='{}/{}.json'.format(
                    self.app,
                    self.name
                ))
            ) as mock:
                ret = getattr(nb, self.name).all()
                self.assertTrue(ret)
                self.assertTrue(isinstance(ret, list))
                self.assertTrue(isinstance(ret[0], self.ret))
                mock.assert_called_with(
                    'http://localhost:8000/api/{}/{}/'.format(
github digitalocean / pynetbox / tests / test_tenancy.py View on Github external
api = pynetbox.api(
    "http://localhost:8000",
)

nb = api.tenancy

HEADERS = {
    'accept': 'application/json;'
}


class Generic(object):
    class Tests(unittest.TestCase):
        name = ''
        ret = pynetbox.core.response.Record
        app = 'tenancy'

        def test_get_all(self):
            with patch(
                'pynetbox.core.query.requests.sessions.Session.get',
                return_value=Response(fixture='{}/{}.json'.format(
                    self.app,
                    self.name
                ))
            ) as mock:
                ret = getattr(nb, self.name).all()
                self.assertTrue(ret)
                self.assertTrue(isinstance(ret, list))
                self.assertTrue(isinstance(ret[0], self.ret))
                mock.assert_called_with(
                    'http://localhost:8000/api/{}/{}/'.format(
github digitalocean / pynetbox / tests / test_virtualization.py View on Github external
api = pynetbox.api(
    "http://localhost:8000",
)

nb = api.virtualization

HEADERS = {
    'accept': 'application/json;'
}


class Generic(object):
    class Tests(unittest.TestCase):
        name = ''
        ret = pynetbox.core.response.Record
        app = 'virtualization'

        def test_get_all(self):
            with patch(
                'pynetbox.core.query.requests.sessions.Session.get',
                return_value=Response(fixture='{}/{}.json'.format(
                    self.app,
                    self.name
                ))
            ) as mock:
                ret = getattr(nb, self.name).all()
                self.assertTrue(ret)
                self.assertTrue(isinstance(ret, list))
                self.assertTrue(isinstance(ret[0], self.ret))
                mock.assert_called_with(
                    'http://localhost:8000/api/{}/{}/'.format(
github digitalocean / pynetbox / tests / test_circuits.py View on Github external
api = pynetbox.api(
    "http://localhost:8000",
)

nb = api.circuits

HEADERS = {
    'accept': 'application/json;'
}


class Generic(object):
    class Tests(unittest.TestCase):
        name = ''
        ret = pynetbox.core.response.Record
        app = 'circuits'

        def test_get_all(self):
            with patch(
                'pynetbox.core.query.requests.sessions.Session.get',
                return_value=Response(fixture='{}/{}.json'.format(
                    self.app,
                    self.name
                ))
            ) as mock:
                ret = getattr(nb, self.name).all()
                self.assertTrue(ret)
                self.assertTrue(isinstance(ret, list))
                self.assertTrue(isinstance(ret[0], self.ret))
                mock.assert_called_with(
                    'http://localhost:8000/api/{}/{}/'.format(
github digitalocean / pynetbox / tests / test_ipam.py View on Github external
HEADERS = {
    'accept': 'application/json;',
    'authorization': 'Token abc123',
}

POST_HEADERS = {
    'Content-Type': 'application/json;',
    'authorization': 'Token abc123',
}


class Generic(object):
    class Tests(unittest.TestCase):
        name = ''
        name_singular = None
        ret = pynetbox.core.response.Record
        app = 'ipam'

        def test_get_all(self):
            with patch(
                'pynetbox.core.query.requests.sessions.Session.get',
                return_value=Response(fixture='{}/{}.json'.format(
                    self.app,
                    self.name
                ))
            ) as mock:
                ret = getattr(nb, self.name).all()
                self.assertTrue(ret)
                self.assertTrue(isinstance(ret, list))
                self.assertTrue(isinstance(ret[0], self.ret))
                mock.assert_called_with(
                    'http://localhost:8000/api/{}/{}/'.format(