Skip to content

Commit f963014

Browse files
committed
Adding tag spec.
1 parent b891522 commit f963014

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

intercom/tag.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from intercom.user import Resource
22
from intercom.api_operations.count import Count
33
from 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

tests/unit/__init__.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff 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

tests/unit/tag_spec.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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

0 commit comments

Comments
 (0)