Skip to content

Commit

Permalink
feat: Add test flag
Browse files Browse the repository at this point in the history
Signed-off-by: Hari-Nagarajan <[email protected]>
  • Loading branch information
Hari-Nagarajan committed Sep 25, 2020
1 parent 16bf5e7 commit 51ccf7e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 3 additions & 6 deletions cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,12 @@ def nvidia(gpu, locale, test, interval):
@click.command()
@click.option("--no-image", is_flag=True)
@click.option("--headless", is_flag=True)
def amazon(no_image, headless,):
@click.option("--test", is_flag=True)
def amazon(no_image, headless):
if no_image:
selenium_utils.no_amazon_image()
amzn_obj = Amazon(headless=headless)
amzn_obj.run_item()

if no_image:
selenium_utils.no_amazon_image()

amzn_obj.run_item(test=test)

@click.command()
@click.option("--sku", type=str, required=True)
Expand Down
6 changes: 3 additions & 3 deletions stores/amazon.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ def login(self):

log.info(f"Logged in as {self.username}")

def run_item(self, delay=3):
def run_item(self, delay=3, test=False):
log.info("Checking stock for items.")
while not self.something_in_stock():
time.sleep(delay)
self.notification_handler.send_notification("Your items on Amazon.com were found!")
self.checkout()
self.checkout(test=test)

def something_in_stock(self):
params = {
Expand All @@ -96,7 +96,7 @@ def something_in_stock(self):
else:
return False

def checkout(self, test=True):
def checkout(self, test):
log.info("Clicking continue.")
self.driver.find_element_by_xpath('//input[@value="add"]').click()
selenium_utils.wait_for_page(self.driver, "Amazon.com Shopping Cart")
Expand Down

0 comments on commit 51ccf7e

Please sign in to comment.