Skip to content

Commit

Permalink
updated files and added automated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Nneji123 committed Mar 23, 2023
1 parent f213008 commit c5c0133
Show file tree
Hide file tree
Showing 18 changed files with 891 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# DATABASE AND SERVER CONFIG
POSTGRES = "postgresql://postgres:password@url:port/database" # POST SERVER
SQLITE = "sqlite:///../database.db" # LOCATION OF SQLITE DATABASE
SQLITE = "sqlite:///./database.db" # LOCATION OF SQLITE DATABASE
SERVER_NAME="http://127.0.0.1:3000" # CHANGE THIS TO YOUR PRODUCTION SERVER LINK
SERVER_MODE="DEV" # CHANGE TO `PROD` TO ENABLE PRODUCTION READY SETTINGS
SERIAL="secret" # FOR GENERATING EMAIL HASHCODE
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python Tests

on: [push]

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Run build script
run: |
apt-get update && apt-get ffmpeg libsm6 build-essential cmake libxext6
pip install --upgrade setuptools
pip install dlib --verbose
cd src
pip install -r requirements.txt
shell: bash
- name: Install dependencies
run: |
cd tests
python -m pip install --upgrade pip
pip install pytest
- name: Test with pytest
uses: dariocurr/pytest-summary@main
with:
output: test-summary.md
paths: tests/**.py
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.env
database.db
src/database.db
__pycache__/
.pytest_cache/
env/
instance/
*.pdf
Expand Down
29 changes: 29 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Create virtual environment
venv:
python -m venv env

# Activate virtual environment
activate:
source env/Scripts/activate

# Lint files
lint:
black src && isort src

# Install requirements
install:
cd src && pip install -r requirements.txt

# Run init script
init:
sh init.sh

# Start application
start:
python app.py

tests:
cd tests && pytest . -W ignore::DeprecationWarning --verbose --html=report.html

# Default target
all: venv activate install init start
10 changes: 8 additions & 2 deletions src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@

from configurations.config import configs
from configurations.extensions import db, email, login_manager, socketio
from configurations.models import (Admins, AdminsView, Lecturers,
LecturersView, Students, StudentsView)
from configurations.models import (
Admins,
AdminsView,
Lecturers,
LecturersView,
Students,
StudentsView,
)
from views.custom_errors import custom_error
from views.index import CustomIndexView, index
from views.lecturer import lecturer
Expand Down
5 changes: 0 additions & 5 deletions src/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ def create_admin():

if __name__ == "__main__":
db.create_all()
print("Created Database!")
create_admin()
print("Created Admin!")
create_dummy_users()
("Print created Users!")
make_dirs()
print("Created Directories")
print("APPLICATION SETUP COMPLETE!..")
4 changes: 3 additions & 1 deletion src/init.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/bin/bash
for i in {1..20}; do python init.py; done
echo "SETTING UP APPLICATION..."
for i in {1..20}; do python init.py; done
echo "APPLICATION SETUP COMPLETE!"

This file was deleted.

Empty file added src/tests/__init__.py
Empty file.
186 changes: 186 additions & 0 deletions src/tests/assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 12px;
/* do not increase min-width as some may use split screens */
min-width: 800px;
color: #999;
}

h1 {
font-size: 24px;
color: black;
}

h2 {
font-size: 16px;
color: black;
}

p {
color: black;
}

a {
color: #999;
}

table {
border-collapse: collapse;
}

/******************************
* SUMMARY INFORMATION
******************************/
#environment td {
padding: 5px;
border: 1px solid #E6E6E6;
}
#environment tr:nth-child(odd) {
background-color: #f6f6f6;
}

/******************************
* TEST RESULT COLORS
******************************/
span.passed,
.passed .col-result {
color: green;
}

span.skipped,
span.xfailed,
span.rerun,
.skipped .col-result,
.xfailed .col-result,
.rerun .col-result {
color: orange;
}

span.error,
span.failed,
span.xpassed,
.error .col-result,
.failed .col-result,
.xpassed .col-result {
color: red;
}

/******************************
* RESULTS TABLE
*
* 1. Table Layout
* 2. Extra
* 3. Sorting items
*
******************************/
/*------------------
* 1. Table Layout
*------------------*/
#results-table {
border: 1px solid #e6e6e6;
color: #999;
font-size: 12px;
width: 100%;
}
#results-table th,
#results-table td {
padding: 5px;
border: 1px solid #E6E6E6;
text-align: left;
}
#results-table th {
font-weight: bold;
}

/*------------------
* 2. Extra
*------------------*/
.log {
background-color: #e6e6e6;
border: 1px solid #e6e6e6;
color: black;
display: block;
font-family: "Courier New", Courier, monospace;
height: 230px;
overflow-y: scroll;
padding: 5px;
white-space: pre-wrap;
}
.log:only-child {
height: inherit;
}

div.image {
border: 1px solid #e6e6e6;
float: right;
height: 240px;
margin-left: 5px;
overflow: hidden;
width: 320px;
}
div.image img {
width: 320px;
}

div.video {
border: 1px solid #e6e6e6;
float: right;
height: 240px;
margin-left: 5px;
overflow: hidden;
width: 320px;
}
div.video video {
overflow: hidden;
width: 320px;
height: 240px;
}

.collapsed {
display: none;
}

.expander::after {
content: " (show details)";
color: #BBB;
font-style: italic;
cursor: pointer;
}

.collapser::after {
content: " (hide details)";
color: #BBB;
font-style: italic;
cursor: pointer;
}

/*------------------
* 3. Sorting items
*------------------*/
.sortable {
cursor: pointer;
}

.sort-icon {
font-size: 0px;
float: left;
margin-right: 5px;
margin-top: 5px;
/*triangle*/
width: 0;
height: 0;
border-left: 8px solid transparent;
border-right: 8px solid transparent;
}
.inactive .sort-icon {
/*finish triangle*/
border-top: 8px solid #E6E6E6;
}
.asc.active .sort-icon {
/*finish triangle*/
border-bottom: 8px solid #999;
}
.desc.active .sort-icon {
/*finish triangle*/
border-top: 8px solid #999;
}
Binary file added src/tests/database.db
Binary file not shown.

0 comments on commit c5c0133

Please sign in to comment.