Skip to content

Commit b891522

Browse files
committed
Adding the note spec.
1 parent 52c18f8 commit b891522

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

intercom/note.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from intercom.user import Resource
22
from intercom.api_operations.find import Find
3+
from intercom.api_operations.save import Save
34

45

5-
class Note(Resource, Find):
6+
class Note(Resource, Find, Save):
67
pass

tests/unit/note_spec.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import httpretty
2+
import json
3+
import re
4+
from describe import expect
5+
from intercom.note import Note
6+
7+
post = httpretty.POST
8+
r = re.compile
9+
10+
11+
class DescribeIntercomNote:
12+
13+
@httpretty.activate
14+
def it_creates_a_note(self):
15+
data = {
16+
'body': '<p>Note to leave on user</p>',
17+
'created_at': 1234567890
18+
}
19+
httpretty.register_uri(
20+
post, r(r'/notes/$'), body=json.dumps(data))
21+
note = Note.create(body="Note to leave on user")
22+
expect(note.body) == "<p>Note to leave on user</p>"
23+
24+
@httpretty.activate
25+
def it_sets_gets_allowed_keys(self):
26+
params = {
27+
'body': 'Note body',
28+
'email': 'me@example.com',
29+
'user_id': 'abc123'
30+
}
31+
params_keys = params.keys()
32+
params_keys.sort()
33+
34+
note = Note(**params)
35+
note_dict = note.to_dict
36+
note_keys = note_dict.keys()
37+
note_keys.sort()
38+
39+
expect(params_keys) == note_keys
40+
for key in params_keys:
41+
expect(getattr(note, key)) == params[key]

0 commit comments

Comments
 (0)