Skip to content

Commit a3cf7e2

Browse files
author
Zach Moody
authored
Merge pull request #76 from digitalocean/circuit-repr
Circuit Repr
2 parents ceb8e48 + ec9d582 commit a3cf7e2

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

pynetbox/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
limitations under the License.
1515
'''
1616
from pynetbox.lib import Endpoint, Request
17-
from pynetbox import dcim, ipam, virtualization
17+
from pynetbox import dcim, ipam, virtualization, circuits
1818

1919

2020
class App(object):
@@ -119,7 +119,7 @@ def __init__(self, url, token=None, private_key=None,
119119

120120
self.dcim = App(dcim, api_kwargs=self.api_kwargs)
121121
self.ipam = App(ipam, api_kwargs=self.api_kwargs)
122-
self.circuits = App('circuits', api_kwargs=self.api_kwargs)
122+
self.circuits = App(circuits, api_kwargs=self.api_kwargs)
123123
self.secrets = App('secrets', api_kwargs=self.api_kwargs)
124124
self.tenancy = App('tenancy', api_kwargs=self.api_kwargs)
125125
self.extras = App('extras', api_kwargs=self.api_kwargs)

pynetbox/circuits.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
'''
2+
(c) 2017 DigitalOcean
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
'''
16+
from pynetbox.lib.response import Record
17+
18+
19+
class Circuits(Record):
20+
21+
def __str__(self):
22+
return self.cid

tests/test_circuits.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,14 @@ def test_get(self):
9292
class CircuitsTestCase(unittest.TestCase, GenericTest):
9393
name = 'circuits'
9494

95+
@patch(
96+
'pynetbox.lib.query.requests.get',
97+
return_value=Response(fixture='circuits/circuit.json')
98+
)
99+
def test_repr(self, _):
100+
test = nb.circuits.get(1)
101+
self.assertEqual(str(test), '123456')
102+
95103

96104
class ProviderTestCase(unittest.TestCase, GenericTest):
97105
name = 'providers'

0 commit comments

Comments
 (0)