Add tests for invalid return types
This commit is contained in:
parent
2237d43854
commit
a97851b82a
2 changed files with 16 additions and 0 deletions
|
@ -63,6 +63,14 @@ class TestActionCreate(TestActions):
|
|||
with self.assertRaises(NotImplementedError):
|
||||
self.client.action.create(target=object(), foo="bar")
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_action_create_invalid_return_type(self, mock_post):
|
||||
"""Check that an exception is raised if an non photo object is returned"""
|
||||
mock_post.return_value = self._return_value({"target": "test",
|
||||
"target_type": "invalid"})
|
||||
with self.assertRaises(NotImplementedError):
|
||||
self.client.action.create(target=self.test_photos[0], foo="bar")
|
||||
|
||||
class TestActionDelete(TestActions):
|
||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||
def test_action_delete(self, mock_post):
|
||||
|
|
|
@ -117,3 +117,11 @@ class TestActivityView(TestActivities):
|
|||
activity.view(foo="bar")
|
||||
mock_get.assert_called_with("/activity/1/view.json", foo="bar")
|
||||
self.assertEqual(activity.get_fields(), self.test_activities_dict[1])
|
||||
|
||||
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||
def test_activity_view_invalid_type(self, mock_get):
|
||||
"""Check that an invalid activity type raises an exception"""
|
||||
mock_get.return_value = self._return_value(self._view_wrapper(
|
||||
{"data": "", "type": "invalid"}))
|
||||
with self.assertRaises(NotImplementedError):
|
||||
self.client.activity.view(self.test_activities[0], foo="bar")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue