Beispiel #1
0
   def setUp(self):
      self.engine = create_engine('mysql://*****:*****@localhost/giltalchemy')
      Session = sessionmaker(bind=self.engine)
      self.session = Session()

      api_key = getenv("GILTAPIKEY")
      if api_key == None:
         raise Exception("Set the environment variable GILTAPIKEY to your API key")
      self.giltClient = GiltClient(api_key)
      self.giltAlchemy = GiltAlchemy()
Beispiel #2
0
class TestBasic(unittest.TestCase):
   @classmethod
   def setUpClass(cls):
      pass

   def setUp(self):
      self.engine = create_engine('mysql://*****:*****@localhost/giltalchemy')
      Session = sessionmaker(bind=self.engine)
      self.session = Session()

      api_key = getenv("GILTAPIKEY")
      if api_key == None:
         raise Exception("Set the environment variable GILTAPIKEY to your API key")
      self.giltClient = GiltClient(api_key)
      self.giltAlchemy = GiltAlchemy()

   def reset_schema(self):
      self.giltAlchemy.drop_all_tables(self.engine)
      self.giltAlchemy.create_all_tables(self.engine)

   def test_persist_all_mens_products_for_one_sale(self):
      self.reset_schema()
      self.delete_all_data()
      active_sales = self.giltClient.active("men")
      for sale in active_sales:
         product_urls = sale.product_urls
         for product_url in product_urls:
            product = self.giltClient.product_detail(product_url)
            self.session.add(product)
            self.session.commit()
         # break;


   def delete_all_data(self):
     self.session.query(Product).filter().delete()
     self.session.query(Sale).filter().delete()
     self.session.query(SKU).filter().delete()
     self.session.query(Image).filter().delete()

   def tearDown(self):
      self.giltAlchemy.clear_mappers()
Beispiel #3
0
class TestGet(unittest.TestCase):
   def setUp(self):
      api_key = getenv("GILTAPIKEY")
      if api_key == None:
         raise Exception("Set the environment variable GILTAPIKEY to your API key")
      self.giltClient = GiltClient(api_key)

   def test_get_active_sale(self):
      active_sales = self.giltClient.active("men")
      sale = active_sales[0]
      # print "Found Sale name = %s" % sale.name
      self.assertTrue(len(sale.name) > 5)

   def test_get_product(self):
      active_sales = self.giltClient.active("women")
      sale = active_sales[0]
      product_url = sale.product_urls[0]
      product = self.giltClient.product_detail(product_url)
      # print "Found Product name = %s" % product.name
      self.assertTrue(len(product.name) > 5)

   def test_product_image(self):
      active_sales = self.giltClient.active("kids")
      sale = active_sales[0]
      product_url = sale.product_urls[0]
      product = self.giltClient.product_detail(product_url)
      image = product.images[0]
      # print "Found Product image = %s" % image.url
      self.assertTrue(image.width > 10)

   def test_product_sku(self):
      active_sales = self.giltClient.active("kids")
      sale = active_sales[0]
      product_url = sale.product_urls[0]
      product = self.giltClient.product_detail(product_url)
      sku = product.skus[0]
Beispiel #4
0
 def setUp(self):
    api_key = getenv("GILTAPIKEY")
    if api_key == None:
       raise Exception("Set the environment variable GILTAPIKEY to your API key")
    self.giltClient = GiltClient(api_key)