Added tests for invalid user_items arguments.
This commit is contained in:
parent
2502c099a3
commit
61cd2beef8
23
tests.py
23
tests.py
@ -158,6 +158,13 @@ class TestUserItems(BaseTestCase):
|
|||||||
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji))
|
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji))
|
||||||
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary))
|
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary))
|
||||||
|
|
||||||
|
def test_filter_invalid_type(self):
|
||||||
|
user = self.get_user()
|
||||||
|
self.login(user)
|
||||||
|
response = self.client.get('/user_items?item_types=invalid')
|
||||||
|
response = json.loads(response.data)
|
||||||
|
self.assertEqual(response, dict(error='No items within these filter parameters'))
|
||||||
|
|
||||||
def test_filter_single_level(self):
|
def test_filter_single_level(self):
|
||||||
test_data = [1]
|
test_data = [1]
|
||||||
user = self.get_user()
|
user = self.get_user()
|
||||||
@ -178,6 +185,14 @@ class TestUserItems(BaseTestCase):
|
|||||||
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji, level_range=test_data))
|
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji, level_range=test_data))
|
||||||
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary, level_range=test_data))
|
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary, level_range=test_data))
|
||||||
|
|
||||||
|
def test_filter_invalid_levels(self):
|
||||||
|
test_data = [0, 61, 1000]
|
||||||
|
user = self.get_user()
|
||||||
|
self.login(user)
|
||||||
|
response = self.client.get('/user_items?level_range=' + (self.flatten_list_to_string(test_data)))
|
||||||
|
response = json.loads(response.data)
|
||||||
|
self.assertEqual(response, dict(error='No items within these filter parameters'))
|
||||||
|
|
||||||
def test_filter_single_state(self):
|
def test_filter_single_state(self):
|
||||||
test_data = ['enlighten']
|
test_data = ['enlighten']
|
||||||
user = self.get_user()
|
user = self.get_user()
|
||||||
@ -198,6 +213,14 @@ class TestUserItems(BaseTestCase):
|
|||||||
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji, test_data))
|
self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji, test_data))
|
||||||
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary, test_data))
|
self.assertEqual(response['vocabulary_count'], self.count_filter(self.user_vocabulary, test_data))
|
||||||
|
|
||||||
|
def test_filter_invalid_state(self):
|
||||||
|
test_data = ['invalid', 'alsoinvalid']
|
||||||
|
user = self.get_user()
|
||||||
|
self.login(user)
|
||||||
|
response = self.client.get('/user_items?item_state=' + (self.flatten_list_to_string(test_data)))
|
||||||
|
response = json.loads(response.data)
|
||||||
|
self.assertEqual(response, dict(error='No items within these filter parameters'))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user