-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from CSE2102-Spring25/develop
Develop->Main
- Loading branch information
Showing
11 changed files
with
2,002 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Backend CI | ||
|
||
on: | ||
push: | ||
paths: | ||
- 'backend/**' | ||
pull_request: | ||
paths: | ||
- 'backend/**' | ||
|
||
jobs: | ||
backend-ci: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.11' | ||
|
||
- name: Install dependencies | ||
working-directory: ./backend | ||
run: | | ||
pip install -r requirements.txt | ||
- name: Run pylint on backend | ||
working-directory: ./backend | ||
run: | | ||
pylint main.py db.py init_db.py | ||
- name: Run Pytest | ||
working-directory: ./backend | ||
run: | | ||
python main.py & # Run server | ||
sleep 5 # Give it time to start | ||
pytest tests/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import sqlite3 | ||
import os | ||
|
||
def init_db(): | ||
"""Initialize the database, creating tables and inserting initial data.""" | ||
db_path = os.path.join(os.path.dirname(__file__), 'animal_shelter.db') | ||
|
||
if os.path.exists(db_path): | ||
print("Database already initialized.") | ||
return | ||
|
||
# Connect to SQLite database (it will create the file if it doesn't exist) | ||
conn = sqlite3.connect(db_path) | ||
cursor = conn.cursor() | ||
|
||
# Create tables | ||
cursor.execute('''CREATE TABLE IF NOT EXISTS animals ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
name TEXT NOT NULL, | ||
species TEXT NOT NULL, | ||
breed TEXT, | ||
age INTEGER, | ||
personality TEXT, | ||
image_path TEXT, | ||
adoption_status TEXT DEFAULT 'Available' | ||
)''') | ||
|
||
cursor.execute('''CREATE TABLE IF NOT EXISTS adopters ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
username TEXT UNIQUE NOT NULL, | ||
password TEXT NOT NULL, | ||
email TEXT UNIQUE, | ||
join_date TEXT DEFAULT CURRENT_TIMESTAMP | ||
)''') | ||
|
||
# Insert initial data (e.g., a test animal) | ||
cursor.execute('''INSERT INTO animals (name, species, breed, age, personality, image_path) | ||
VALUES (?, ?, ?, ?, ?, ?)''', | ||
('TestDog', 'Dog', 'Mixed', 2, 'Friendly', '/images/test.jpg')) | ||
|
||
conn.commit() | ||
conn.close() | ||
print("Database initialized and initial data inserted.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.