Skip to content

Commit 5030836

Browse files
committed
Completely removed HTTPretty now.
1 parent ffa4244 commit 5030836

File tree

8 files changed

+44
-41
lines changed

8 files changed

+44
-41
lines changed

dev-requirements.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
# Development dependencies.
33
#
44
nose==1.3.4
5-
httpretty==0.8.6
65
mock==1.0.1
7-
coverage==3.7.1
8-
Sphinx==1.3.1

intercom/traits/api_resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def attributes(self):
7878
return res
7979

8080
def submittable_attribute(self, name, value):
81-
return name in self.changed_attributes or (isinstance(value, FlatStore) and name in self.flat_store_attributes)  # noqa
81+
return name in self.changed_attributes or (isinstance(value, FlatStore) and name in self.flat_store_attributes) # noqa
8282

8383
def __getattribute__(self, attribute):
8484
value = super(Resource, self).__getattribute__(attribute)

tests/integration/issues/test_73.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
How do I record when a User has started a new session?
4+
"""
5+
6+
import os
7+
import unittest
8+
from intercom import Intercom
9+
from intercom import User
10+
11+
Intercom.app_id = os.environ.get('INTERCOM_APP_ID')
12+
Intercom.app_api_key = os.environ.get('INTERCOM_APP_API_KEY')
13+
14+
15+
class Issue73Test(unittest.TestCase):
16+
17+
def test(self):
18+
user = User.create(email='me@example.com')
19+
# store current session count
20+
session_count = user.session_count
21+
22+
import time
23+
time.sleep(30)
24+
# register a new session
25+
user.new_session = True
26+
user.save()
27+
28+
# count has increased by 1
29+
self.assertEquals(session_count + 1, user.session_count)
30+
31+
import time
32+
time.sleep(30)
33+
# register a new session
34+
user.new_session = True
35+
user.save()
36+
37+
# count has increased by 1
38+
self.assertEquals(session_count + 2, user.session_count)

tests/unit/test_event.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import httpretty
43
import time
54
import unittest
65

@@ -41,7 +40,6 @@ def it_creates_an_event_with_metadata(self):
4140
mock_method.assert_called_once_with('/events/', **data)
4241

4342
@istest
44-
@httpretty.activate
4543
def it_creates_an_event_without_metadata(self):
4644
data = {
4745
'event_name': 'sale of item',

tests/unit/test_note.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import httpretty
4-
import json
5-
import re
63
import unittest
74

85
from intercom import Intercom
@@ -11,30 +8,21 @@
118
from nose.tools import eq_
129
from nose.tools import istest
1310

14-
post = httpretty.POST
15-
r = re.compile
16-
1711

1812
class NoteTest(unittest.TestCase):
1913

2014
@istest
21-
@httpretty.activate
2215
def it_creates_a_note(self):
2316
data = {
2417
'body': '<p>Note to leave on user</p>',
2518
'created_at': 1234567890
2619
}
2720
with patch.object(Intercom, 'post', return_value=data) as mock_method:
28-
# message = Message.create(**data)
29-
# eq_('halp', message.body)
30-
# httpretty.register_uri(
31-
# post, r(r'/notes/$'), body=json.dumps(data))
3221
note = Note.create(body="Note to leave on user")
33-
mock_method.assert_called_once_with('/notes/', body="Note to leave on user")
22+
mock_method.assert_called_once_with('/notes/', body="Note to leave on user") # noqa
3423
eq_(note.body, "<p>Note to leave on user</p>")
3524

3625
@istest
37-
@httpretty.activate
3826
def it_sets_gets_allowed_keys(self):
3927
params = {
4028
'body': 'Note body',

tests/unit/test_request.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ def it_raises_authentication_error_unauthorized(self):
4040
Request.send_request_to_path('GET', 'notes', ('x', 'y'), resp)
4141

4242
@istest
43-
# @httpretty.activate
4443
def it_raises_authentication_error_forbidden(self):
4544
resp = Mock(content='{}', status_code=403)
4645
with patch('requests.request') as mock_method:
@@ -49,7 +48,6 @@ def it_raises_authentication_error_forbidden(self):
4948
Request.send_request_to_path('GET', 'notes', ('x', 'y'), resp)
5049

5150
@istest
52-
# @httpretty.activate
5351
def it_raises_server_error(self):
5452
resp = Mock(content='{}', status_code=500)
5553
with patch('requests.request') as mock_method:
@@ -58,7 +56,6 @@ def it_raises_server_error(self):
5856
Request.send_request_to_path('GET', 'notes', ('x', 'y'), resp)
5957

6058
@istest
61-
# @httpretty.activate
6259
def it_raises_bad_gateway_error(self):
6360
resp = Mock(content='{}', status_code=502)
6461
with patch('requests.request') as mock_method:
@@ -67,7 +64,6 @@ def it_raises_bad_gateway_error(self):
6764
Request.send_request_to_path('GET', 'notes', ('x', 'y'), resp)
6865

6966
@istest
70-
# @httpretty.activate
7167
def it_raises_service_unavailable_error(self):
7268
resp = Mock(content='{}', status_code=503)
7369
with patch('requests.request') as mock_method:

tests/unit/test_subscription.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# -*- coding: utf-8 -*-
22

3-
import httpretty
4-
import re
53
import unittest
64

75
from intercom import Intercom
@@ -11,11 +9,6 @@
119
from nose.tools import istest
1210
from tests.unit import test_subscription
1311

14-
get = httpretty.GET
15-
post = httpretty.POST
16-
17-
r = re.compile
18-
1912

2013
class SubscriptionTest(unittest.TestCase):
2114

tests/unit/test_user.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# -*- coding: utf-8 -*-
22

3-
import httpretty
43
import json
54
import mock
6-
import re
75
import time
86
import unittest
97

@@ -23,13 +21,6 @@
2321
from tests.unit import get_user
2422

2523

26-
get = httpretty.GET
27-
post = httpretty.POST
28-
delete = httpretty.DELETE
29-
30-
r = re.compile
31-
32-
3324
class UserTest(unittest.TestCase):
3425

3526
@istest
@@ -130,8 +121,10 @@ def it_allows_update_last_request_at(self):
130121
'update_last_request_at': True,
131122
'custom_attributes': {}
132123
}
133-
httpretty.register_uri(post, r("/users"), body=json.dumps(payload))
134-
User(user_id='1224242', update_last_request_at=True)
124+
with patch.object(Intercom, 'post', return_value=payload) as mock_method:
125+
User.create(user_id='1224242', update_last_request_at=True)
126+
mock_method.assert_called_once_with(
127+
'/users/', update_last_request_at=True, user_id='1224242')
135128

136129
@istest
137130
def it_allows_easy_setting_of_custom_data(self):

0 commit comments

Comments
 (0)