File tree Expand file tree Collapse file tree 2 files changed +62
-0
lines changed
Expand file tree Collapse file tree 2 files changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ from intercom .user import Resource
2+ from intercom .api_operations .save import Save
3+
4+
5+ class Message (Resource , Save ):
6+ pass
Original file line number Diff line number Diff line change 1+ import httpretty
2+ import json
3+ import re
4+ import time
5+ from datetime import datetime
6+ from describe import expect
7+ from intercom .user import User
8+ from intercom .message import Message
9+
10+ post = httpretty .POST
11+ r = re .compile
12+
13+
14+ class DescribeIntercomEvent :
15+ def before_each (self , context ):
16+ now = time .mktime (datetime .utcnow ().timetuple ())
17+ self .user = User (
18+ email = "jim@example.com" ,
19+ user_id = "12345" ,
20+ created_at = now ,
21+ name = "Jim Bob" )
22+ self .created_time = now - 300
23+
24+ @httpretty .activate
25+ def it_creates_a_user_message_with_string_keys (self ):
26+ data = {
27+ 'from' : {
28+ 'type' : 'user' ,
29+ 'email' : 'jim@example.com' ,
30+ },
31+ 'body' : 'halp'
32+ }
33+ httpretty .register_uri (
34+ post , r (r'/messages/$' ), body = json .dumps (data ), status = 200 )
35+ message = Message .create (** data )
36+ expect ('halp' ) == message .body
37+
38+ @httpretty .activate
39+ def it_creates_an_admin_message (self ):
40+ data = {
41+ 'from' : {
42+ 'type' : 'admin' ,
43+ 'id' : '1234' ,
44+ },
45+ 'to' : {
46+ 'type' : 'user' ,
47+ 'id' : '5678' ,
48+ },
49+ 'body' : 'halp' ,
50+ 'message_type' : 'inapp'
51+ }
52+ httpretty .register_uri (
53+ post , r (r'/messages/$' ), body = json .dumps (data ), status = 200 )
54+ message = Message .create (** data )
55+ expect ('halp' ) == message .body
56+ expect ('inapp' ) == message .message_type
You can’t perform that action at this time.
0 commit comments