Ejemplo n.º 1
0
 def test_get_seller_from_listing(self):
     papi = PAPI(deepcopy(TEST_RESPONSE))
     products = papi.get_products_from_response()
     offerings0 = papi.get_offerings_from_product(products[0])
     offerings1 = papi.get_offerings_from_product(products[1])
     offerings2 = papi.get_offerings_from_product(products[2])
     self.assertEqual(papi.get_seller_from_listing(offerings0[0]), "Amazon")
     self.assertEqual(papi.get_seller_from_listing(offerings0[1]), "Merchant")
     offerings0[0]["Qualifiers"]["FulfillmentChannel"] = {}
     # catch KeyError
     self.assertEqual(papi.get_seller_from_listing(offerings0[0]), None)
     # Test response as a dict
     papi2 = PAPI(deepcopy(TEST_RESPONSE_SM))
     products = papi2.get_products_from_response()
     offerings0 = papi.get_offerings_from_product(products[0])
     seller = papi2.get_seller_from_listing(offerings0[0])
     self.assertEqual(seller, "Amazon")
Ejemplo n.º 2
0
 def test_get_seller_from_listing(self):
     papi = PAPI(deepcopy(TEST_RESPONSE))
     products = papi.get_products_from_response()
     offerings0 = papi.get_offerings_from_product(products[0])
     offerings1 = papi.get_offerings_from_product(products[1])
     offerings2 = papi.get_offerings_from_product(products[2])
     self.assertEqual(papi.get_seller_from_listing(offerings0[0]), 'Amazon')
     self.assertEqual(papi.get_seller_from_listing(offerings0[1]),
                      'Merchant')
     offerings0[0]['Qualifiers']['FulfillmentChannel'] = {}
     # catch KeyError
     self.assertEqual(papi.get_seller_from_listing(offerings0[0]), None)
     # Test response as a dict
     papi2 = PAPI(deepcopy(TEST_RESPONSE_SM))
     products = papi2.get_products_from_response()
     offerings0 = papi.get_offerings_from_product(products[0])
     seller = papi2.get_seller_from_listing(offerings0[0])
     self.assertEqual(seller, 'Amazon')