Test that all types of empty lists are retuned as []
This commit is contained in:
parent
138f47add3
commit
c18e590cc2
4 changed files with 65 additions and 1 deletions
|
@ -52,6 +52,22 @@ class TestActivitiesList(TestActivities):
|
||||||
self.assertEqual(result[1].type, "photo_update")
|
self.assertEqual(result[1].type, "photo_update")
|
||||||
self.assertEqual(result[1].data.id, "photo2")
|
self.assertEqual(result[1].data.id, "photo2")
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_empty_result(self, mock_get):
|
||||||
|
"""Check that an empty result is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value("")
|
||||||
|
result = self.client.activities.list()
|
||||||
|
mock_get.assert_called_with("/activities/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_zero_rows(self, mock_get):
|
||||||
|
"""Check that totalRows=0 is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value([{"totalRows": 0}])
|
||||||
|
result = self.client.activities.list()
|
||||||
|
mock_get.assert_called_with("/activities/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
class TestActivitiesPurge(TestActivities):
|
class TestActivitiesPurge(TestActivities):
|
||||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||||
def test_activity_purge(self, mock_get):
|
def test_activity_purge(self, mock_get):
|
||||||
|
|
|
@ -39,6 +39,22 @@ class TestAlbumsList(TestAlbums):
|
||||||
self.assertEqual(result[1].id, "2")
|
self.assertEqual(result[1].id, "2")
|
||||||
self.assertEqual(result[1].name, "Album 2")
|
self.assertEqual(result[1].name, "Album 2")
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_empty_result(self, mock_get):
|
||||||
|
"""Check that an empty result is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value("")
|
||||||
|
result = self.client.albums.list()
|
||||||
|
mock_get.assert_called_with("/albums/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_zero_rows(self, mock_get):
|
||||||
|
"""Check that totalRows=0 is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value([{"totalRows": 0}])
|
||||||
|
result = self.client.albums.list()
|
||||||
|
mock_get.assert_called_with("/albums/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
@mock.patch.object(trovebox.Trovebox, 'get')
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
def test_albums_list_returns_cover_photos(self, mock_get):
|
def test_albums_list_returns_cover_photos(self, mock_get):
|
||||||
"""Check that the album list returns cover photo objects"""
|
"""Check that the album list returns cover photo objects"""
|
||||||
|
|
|
@ -39,6 +39,22 @@ class TestPhotosList(TestPhotos):
|
||||||
self.assertEqual(result[1].id, "2b")
|
self.assertEqual(result[1].id, "2b")
|
||||||
self.assertEqual(result[1].tags, ["tag3", "tag4"])
|
self.assertEqual(result[1].tags, ["tag3", "tag4"])
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_empty_result(self, mock_get):
|
||||||
|
"""Check that an empty result is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value("")
|
||||||
|
result = self.client.photos.list()
|
||||||
|
mock_get.assert_called_with("/photos/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_zero_rows(self, mock_get):
|
||||||
|
"""Check that totalRows=0 is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value([{"totalRows": 0}])
|
||||||
|
result = self.client.photos.list()
|
||||||
|
mock_get.assert_called_with("/photos/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
class TestPhotosUpdate(TestPhotos):
|
class TestPhotosUpdate(TestPhotos):
|
||||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||||
def test_photos_update(self, mock_post):
|
def test_photos_update(self, mock_post):
|
||||||
|
|
|
@ -25,7 +25,7 @@ class TestTags(unittest.TestCase):
|
||||||
class TestTagsList(TestTags):
|
class TestTagsList(TestTags):
|
||||||
@mock.patch.object(trovebox.Trovebox, 'get')
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
def test_tags_list(self, mock_get):
|
def test_tags_list(self, mock_get):
|
||||||
"""Check that the the tag list is returned correctly"""
|
"""Check that the tag list is returned correctly"""
|
||||||
mock_get.return_value = self._return_value(self.test_tags_dict)
|
mock_get.return_value = self._return_value(self.test_tags_dict)
|
||||||
result = self.client.tags.list()
|
result = self.client.tags.list()
|
||||||
mock_get.assert_called_with("/tags/list.json")
|
mock_get.assert_called_with("/tags/list.json")
|
||||||
|
@ -35,6 +35,22 @@ class TestTagsList(TestTags):
|
||||||
self.assertEqual(result[1].id, "tag2")
|
self.assertEqual(result[1].id, "tag2")
|
||||||
self.assertEqual(result[1].count, 5)
|
self.assertEqual(result[1].count, 5)
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_empty_result(self, mock_get):
|
||||||
|
"""Check that an empty result is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value("")
|
||||||
|
result = self.client.tags.list()
|
||||||
|
mock_get.assert_called_with("/tags/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
|
@mock.patch.object(trovebox.Trovebox, 'get')
|
||||||
|
def test_zero_rows(self, mock_get):
|
||||||
|
"""Check that totalRows=0 is transformed into an empty list """
|
||||||
|
mock_get.return_value = self._return_value([{"totalRows": 0}])
|
||||||
|
result = self.client.tags.list()
|
||||||
|
mock_get.assert_called_with("/tags/list.json")
|
||||||
|
self.assertEqual(result, [])
|
||||||
|
|
||||||
class TestTagCreate(TestTags):
|
class TestTagCreate(TestTags):
|
||||||
@mock.patch.object(trovebox.Trovebox, 'post')
|
@mock.patch.object(trovebox.Trovebox, 'post')
|
||||||
def test_tag_create(self, mock_post):
|
def test_tag_create(self, mock_post):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue