diff --git a/tests.py b/tests.py index fd250fc..b37305c 100644 --- a/tests.py +++ b/tests.py @@ -158,6 +158,13 @@ class TestUserItems(BaseTestCase): self.assertEqual(response['kanji_count'], self.count_filter(self.user_kanji)) 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): test_data = [1] 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['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): test_data = ['enlighten'] 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['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__': unittest.main()