Skip to content

Commit

Permalink
feat: add basic testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jul 10, 2024
1 parent 4cee6a6 commit 56bf5d6
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
9 changes: 4 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ __pycache__/
dist/
*.egg-info

# Automation Scripts
*.sh

# Testing
tests/
# Creds and tokens
*.json
erpcreds.py
.session
15 changes: 15 additions & 0 deletions tests/scripts/test-publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/opt/homebrew/bin/bash

## Change the directory to root directory of the project
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT_DIR=$(dirname "$(dirname "$SCRIPT_DIR")")
cd "${ROOT_DIR}" >/dev/null 2>&1 || { echo "[ERROR]: Failed to cd into root directory of the project" && exit 1; }

nvim pyproject.toml # Update the version
rm -rf dist/ # Delete previous builds
python3 -m build # Build
twine upload --repository testpypi dist/* # Upload to test.pypi
pip uninstall iitkgp_erp_login # Uninstall previous version
version=$(grep -i "version = " pyproject.toml | cut -d'"' -f2) # Get the latest version
pip install -i https://test.pypi.org/simple/ iitkgp-erp-login=="${version}" 2>/dev/null || echo "..." # Just ignore this
pip install -i https://test.pypi.org/simple/ iitkgp-erp-login=="${version}" # Get the latest version
9 changes: 9 additions & 0 deletions tests/scripts/update-local.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

## Change the directory to root directory of the project
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
ROOT_DIR=$(dirname "$(dirname "$SCRIPT_DIR")")
cd "${ROOT_DIR}" >/dev/null 2>&1 || { echo "[ERROR]: Failed to cd into root directory of the project" && exit 1; }

# cp -a ./src/iitkgp_erp_login/* ./venv/lib/python3.*/site-packages/iitkgp_erp_login/
cp -a ./src/iitkgp_erp_login/* /opt/homebrew/lib/python3.*/site-packages/iitkgp_erp_login/
24 changes: 24 additions & 0 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import re
import requests
import time
import erpcreds as erpcreds
import iitkgp_erp_login.erp as erp

headers = {
'timeout': '20',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/51.0.2704.79 Chrome/51.0.2704.79 Safari/537.36',
}
session = requests.Session()

# erp.login(headers, session, LOGGING=True)
erp.login(headers, session, ERPCREDS=erpcreds, LOGGING=True)
# erp.login(headers, session, ERPCREDS=erpcreds, OTP_CHECK_INTERVAL=2, LOGGING=True)
# while True:
# sessionToken, ssoToken = erp.login(headers, session, ERPCREDS=erpcreds, OTP_CHECK_INTERVAL=2, LOGGING=True, SESSION_STORAGE_FILE='.session')
# r = session.get(erp.WELCOMEPAGE_URL)

# status_code = r.status_code
# if status_code == 200:
# print(r.text)
# content_length = r.headers.get("Content-Length")
# break

0 comments on commit 56bf5d6

Please sign in to comment.