This repository was archived by the owner on Nov 7, 2024. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathtest_notes.py
More file actions
75 lines (60 loc) · 2.35 KB
/
Copy pathtest_notes.py
File metadata and controls
75 lines (60 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python
import os
import sys
# For coverage.
if __package__ is None:
sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/..")
from unittest import main, TestCase
import requests
import requests_mock
from iris_sdk.client import Client
from iris_sdk.models.account import Account
XML_RESPONSE_NOTES_GET = (
b"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Notes>"
b"<Note><Id>11425</Id><UserId>byo_dev</UserId>"
b"<Description>Test Note</Description>"
b"<LastDateModifier>2015-06-18T04:19:59.000Z</LastDateModifier></Note>"
b"</Notes>"
)
XML_RESPONSE_NOTES_LIST = (
b"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><Notes>"
b"<Note><Id>11425</Id><UserId>byo_dev</UserId>"
b"<Description>Test Note</Description>"
b"<LastDateModifier>2015-06-18T04:19:59.000Z</LastDateModifier></Note>"
b"<Note><Id>11425</Id><UserId>byo_dev</UserId>"
b"<Description>Test Note</Description>"
b"<LastDateModifier>2015-06-18T04:19:59.000Z</LastDateModifier></Note>"
b"</Notes>"
)
class ClassNotesTest(TestCase):
"""Test the Notes resource"""
@classmethod
def setUpClass(cls):
cls._client = Client("http://foo", "bar", "bar", "qux")
cls._account = Account(client=cls._client)
cls._notes = cls._account.disconnects.create(
{"order_id": "123"}, False).notes
cls._url = cls._client.config.url + cls._notes.get_xpath()
@classmethod
def tearDownClass(cls):
del cls._notes
del cls._account
del cls._client
def test_notes_create(self):
with requests_mock.Mocker() as m:
m.post(self._url, headers={"location": self._url + "/123"})
note = self._notes.create({"user_id":"spam", "description":"ham"})
self.assertEqual(note.id, "123")
def test_notes_get(self):
with requests_mock.Mocker() as m:
m.get(self._url, content=XML_RESPONSE_NOTES_GET)
notes = self._notes.list()
self.assertEqual(notes.items[0].id, "11425")
def test_notes_list(self):
with requests_mock.Mocker() as m:
m.get(self._url, content=XML_RESPONSE_NOTES_LIST)
notes = self._notes.list()
self.assertEqual(len(notes.items), 2)
self.assertEqual(notes.items[0].id, "11425")
if __name__ == "__main__":
main()