Skip to content

Commit

Permalink
Fix broken tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jerith committed Oct 6, 2014
1 parent bf24927 commit 87c137b
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions txtwitter/tests/test_twitter.py
Expand Up @@ -877,6 +877,7 @@ def test_direct_messages_show(self):
resp = yield client.direct_messages_show('1')
self.assertEqual(resp, response_data[0])

@inlineCallbacks
def test_direct_messages_show_not_found(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/show.json'
Expand All @@ -891,13 +892,14 @@ def test_direct_messages_show_not_found(self):
agent.add_expected_request(
'GET', uri, {'id': '1'}, self._resp_json(err_dict, 404))

d = client.direct_messages_show(1)
d = client.direct_messages_show("1")
d.addErrback(lambda f: f.value)
err = yield d

code, _phrase, body = err.args
self.assertEqual((404, err_dict), (code, json.loads(body)))

@inlineCallbacks
def test_direct_messages_show_forbidden(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/show.json'
Expand All @@ -912,7 +914,7 @@ def test_direct_messages_show_forbidden(self):
agent.add_expected_request(
'GET', uri, {'id': '1'}, self._resp_json(err_dict, 403))

d = client.direct_messages_show(1)
d = client.direct_messages_show("1")
d.addErrback(lambda f: f.value)
err = yield d

Expand Down Expand Up @@ -943,6 +945,7 @@ def test_direct_messages_destroy(self):
resp = yield client.direct_messages_destroy('1')
self.assertEqual(resp, response_data)

@inlineCallbacks
def test_direct_messages_destroy_all_params(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/destroy.json'
Expand Down Expand Up @@ -972,6 +975,7 @@ def test_direct_messages_destroy_all_params(self):
'1', include_entities=False)
self.assertEqual(resp, response_data)

@inlineCallbacks
def test_direct_messages_destroy_not_found(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/destroy.json'
Expand All @@ -984,15 +988,16 @@ def test_direct_messages_destroy_not_found(self):
}

agent.add_expected_request(
'GET', uri, {'id': '1'}, self._resp_json(err_dict, 404))
'POST', uri, {'id': '1'}, self._resp_json(err_dict, 404))

d = client.direct_messages_destroy(1)
d = client.direct_messages_destroy("1")
d.addErrback(lambda f: f.value)
err = yield d

code, _phrase, body = err.args
self.assertEqual((404, err_dict), (code, json.loads(body)))

@inlineCallbacks
def test_direct_messages_destroy_forbidden(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/destroy.json'
Expand All @@ -1005,9 +1010,9 @@ def test_direct_messages_destroy_forbidden(self):
}

agent.add_expected_request(
'GET', uri, {'id': '1'}, self._resp_json(err_dict, 403))
'POST', uri, {'id': '1'}, self._resp_json(err_dict, 403))

d = client.direct_messages_destroy(1)
d = client.direct_messages_destroy("1")
d.addErrback(lambda f: f.value)
err = yield d

Expand Down Expand Up @@ -1073,6 +1078,7 @@ def test_direct_messages_new_by_screen_name(self):
'hello', screen_name='fakeuser2')
self.assertEqual(resp, response_data)

@inlineCallbacks
def test_direct_messages_new_bad_request(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/direct_messages/new.json'
Expand All @@ -1087,7 +1093,7 @@ def test_direct_messages_new_bad_request(self):
}

agent.add_expected_request(
'GET', uri, {'id': '1'}, self._resp_json(err_dict, 400))
'POST', uri, {'text': 'hello'}, self._resp_json(err_dict, 403))

d = client.direct_messages_new('hello')
d.addErrback(lambda f: f.value)
Expand Down Expand Up @@ -1173,6 +1179,7 @@ def test_friendships_create_follow(self):
screen_name='fakeuser2', follow=True)
self.assertEqual(resp, response_data)

@inlineCallbacks
def test_friendships_create_forbidden(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/friendships/create.json'
Expand Down Expand Up @@ -1238,6 +1245,7 @@ def test_friendships_destroy_by_screen_name(self):
resp = yield client.friendships_destroy(screen_name='fakeuser2')
self.assertEqual(resp, response_data)

@inlineCallbacks
def test_friendships_destroy_forbidden(self):
agent, client = self._agent_and_TwitterClient()
uri = 'https://api.twitter.com/1.1/friendships/destroy.json'
Expand Down

0 comments on commit 87c137b

Please sign in to comment.