From e3d7766cc1d013398adaa55bd1941010fc698138 Mon Sep 17 00:00:00 2001 From: Jaydin_MacBook Date: Mon, 15 Jan 2024 14:17:15 -0500 Subject: [PATCH] Added Argparse --- .github/workflows/Unit-Tests.yml | 3 ++- backend/test_blackboard_scraper.py | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/Unit-Tests.yml b/.github/workflows/Unit-Tests.yml index 21a97bd..6d3e7b5 100644 --- a/.github/workflows/Unit-Tests.yml +++ b/.github/workflows/Unit-Tests.yml @@ -27,4 +27,5 @@ jobs: - name: Run tests run: | - python backend/test_blackboard_scraper.py + python backend/test_blackboard_scraper.py ${{ secrets.TEST_USERNAME }} ${{ secrets.TEST_PASSWORD }} + diff --git a/backend/test_blackboard_scraper.py b/backend/test_blackboard_scraper.py index d2c6e77..ea471b1 100644 --- a/backend/test_blackboard_scraper.py +++ b/backend/test_blackboard_scraper.py @@ -1,3 +1,4 @@ +import argparse import os import random import time @@ -5,9 +6,19 @@ from dotenv import load_dotenv from blackboard_scraper import BlackboardSession -from unittest.mock import MagicMock, patch +from unittest.mock import patch from usernames import usernames +# Create the parser +parser = argparse.ArgumentParser(description='Test BlackboardSession') + +# Add the arguments +parser.add_argument('--username', type=str, help='Username for login') +parser.add_argument('--password', type=str, help='Password for login') + +# Parse the arguments +args = parser.parse_args() + """" Test Case Senarios: @@ -64,8 +75,8 @@ class TestBlackboardSession(unittest.TestCase): def setUp(self): load_dotenv() - self.username = os.getenv('TEST_USERNAME') - self.password = os.getenv('TEST_PASSWORD') + self.username = args.username if args.username else os.getenv('TEST_USERNAME') + self.password = args.password if args.password else os.getenv('TEST_PASSWORD') # * Login Tests *#