File tree Expand file tree Collapse file tree 3 files changed +49
-9
lines changed
Expand file tree Collapse file tree 3 files changed +49
-9
lines changed Original file line number Diff line number Diff line change 11from intercom .user import Resource
22from intercom .api_operations .count import Count
33from intercom .api_operations .find import Find
4+ from intercom .api_operations .save import Save
45
56
6- class Tag (Resource , Find , Count ):
7+ class Tag (Resource , Find , Count , Save ):
78 pass
Original file line number Diff line number Diff line change @@ -215,14 +215,13 @@ def page_of_users(include_next_link=False):
215215# }
216216# end
217217
218- # def test_tag
219- # {
220- # "id" => "4f73428b5e4dfc000b000112",
221- # "name" => "Test Tag",
222- # "segment" => false,
223- # "tagged_user_count" => 2
224- # }
225- # end
218+ test_tag = {
219+ "id" : "4f73428b5e4dfc000b000112" ,
220+ "name" : "Test Tag" ,
221+ "segment" : False ,
222+ "tagged_user_count" : 2
223+ }
224+
226225
227226# def error_on_modify_frozen
228227# RUBY_VERSION =~ /1.8/ ? TypeError : RuntimeError
Original file line number Diff line number Diff line change 1+ import httpretty
2+ import json
3+ import re
4+ from describe import expect
5+ from intercom .tag import Tag
6+ from tests .unit import test_tag
7+
8+ get = httpretty .GET
9+ post = httpretty .POST
10+ r = re .compile
11+
12+
13+ class DescribeIntercomTag :
14+
15+ @httpretty .activate
16+ def it_gets_a_tag (self ):
17+ httpretty .register_uri (
18+ get , r (r'/tags' ), body = json .dumps (test_tag ))
19+ tag = Tag .find (name = "Test Tag" )
20+ expect (tag .name ) == "Test Tag"
21+
22+ @httpretty .activate
23+ def it_creates_a_tag (self ):
24+ httpretty .register_uri (
25+ post , r (r'/tags' ), body = json .dumps (test_tag ))
26+ tag = Tag .create (name = "Test Tag" )
27+ expect (tag .name ) == "Test Tag"
28+
29+ @httpretty .activate
30+ def it_tags_users (self ):
31+ params = {
32+ 'name' : 'Test Tag' ,
33+ 'user_ids' : ['abc123' , 'def456' ],
34+ 'tag_or_untag' : 'tag'
35+ }
36+ httpretty .register_uri (
37+ post , r (r'/tags' ), body = json .dumps (test_tag ))
38+ tag = Tag .create (** params )
39+ expect (tag .name ) == "Test Tag"
40+ expect (tag .tagged_user_count ) == 2
You can’t perform that action at this time.
0 commit comments