Skip to content

Commit 317cc9d

Browse files
author
Zach Moody
authored
Merge pull request #20 from digitalocean/api-test
api test
2 parents 02b2149 + 4189248 commit 317cc9d

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"session_key": "ansodicnaoiwenafoi="
3+
}

tests/test_api.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import unittest
2+
import six
3+
4+
from .util import Response
5+
import pynetbox
6+
7+
if six.PY3:
8+
from unittest.mock import patch
9+
else:
10+
from mock import patch
11+
12+
13+
class ApiTestCase(unittest.TestCase):
14+
@patch(
15+
'pynetbox.lib.query.requests.post',
16+
return_value=Response(fixture='api/get_session_key.json')
17+
)
18+
def test_get(self, mock):
19+
api = pynetbox.api(
20+
"http://localhost:8000",
21+
token='abc123',
22+
private_key_file='tests/fixtures/api/get_session_key.json',
23+
version='2.0'
24+
)
25+
self.assertTrue(api)

0 commit comments

Comments
 (0)