def testBuildProduct(self):
    models.Category.buildAllCategories()
    self.assertRaises(errors.Error, docs.Product.buildProduct, {})

    product = docs.Product.buildProduct(PRODUCT_PARAMS)

    # make sure that a product entity is stored in Datastore
    self.assert_(product is not None)
    self.assertEqual(product.price, PRODUCT_PARAMS['price'])

    # make sure the search actually works
    sq = search.Query(query_string='Sir Arthur Conan Doyle')
    res = docs.Product.getIndex().search(sq)
    self.assertEqual(res.number_found, 1)
    for doc in res:
      self.assertEqual(doc.doc_id, product.doc_id)
dataset/ETHPy150Open GoogleCloudPlatform/appengine-search-python-java/product_search_python/tests/test_search.py/FTSTestCase.testBuildProduct/original