def list(self, request): ''' Return a list of categories. ''' categories = Category.query().fetch() messages = [] for category in categories: messages.append(category.to_message()) return common_messages.Categories(categories=messages)
def test_category_delete_method(self): ''' Add a category and then delete it through the api. ''' slug = 'test-slug' category_key = db_loader.create_category(slug=slug) params = { 'key': encrypt(category_key.urlsafe()), } response = generic_service_method_success_test(self, 'category', 'delete', params=params) self.assertEqual(response['response']['type'], 'Echo', 'Category put service method failed.') self.assertEqual(len(Category.query().fetch(1)), 0, 'Failed to delete category.')
def test_insert_entity(self): category_key = db_loader.create_category() self.assertTrue(category_key, "Failed to create an entity and return a key.") self.assertEqual(1, len(Category.query().fetch(2)), "Failed to retrieve a stored entity.")