Skip to content

Commit

Permalink
test automation
Browse files Browse the repository at this point in the history
  • Loading branch information
marian-vignau committed Jun 16, 2021
1 parent f27a168 commit 9e88a76
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
playwright install chromium ffmpeg
- name: Serve website locally
run: |
python web2py/web2py.py -a 'admin1234' &
python web2py/web2py.py -a 'admin1234' -p 8020 &
- name: Run PyTest UTs
run: |
cd web2py/applications/OpenLex/
Expand Down
10 changes: 7 additions & 3 deletions models/db_pydoctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
__author__ = "María Andrea Vignau ([email protected])"
__copyright__ = "(C) 2016 María Andrea Vignau. GNU GPL 3."

import os
from gluon.contrib.markdown.markdown2 import markdown
from gluon.tools import *

Expand All @@ -22,9 +23,12 @@
tsv_with_hidden_cols=False,
tsv=False,
json=False)


db = DAL('sqlite://openlex.sqlite')
# import pdb; breakpoint()
if os.getenv('WEB2PY_USE_DB_TESTING'):
temp_dir = '/dev/shm'
db = DAL('sqlite://testing.sqlite', folder=temp_dir)
else:
db = DAL('sqlite://openlex.sqlite')

auth = Auth(globals(), db)
auth.define_tables()
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
# To run chrome with UI pass --headed
addopts = --browser chromium --base-url=http://127.0.0.1:8000/OpenLex/
addopts = --browser chromium --base-url=http://127.0.0.1:8020/OpenLex/
16 changes: 16 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# this variable can be used on creating database
export WEB2PY_USE_DB_TESTING="True"
# default port_number
PORT_NUMBER=8020
# remove all temporary in memory files
rm -f /dev/shm/*.table
rm -f /dev/shm/sql.log
rm -f /dev/shm/testing.sqlite
# run web2py
python ../../web2py.py -a 123 -p ${PORT_NUMBER} --no_gui &
# run tests
fades -r requirements.txt -x pytest -v --pdb
# kill web2py
fuser -k -TERM -n tcp ${PORT_NUMBER} > /dev/null
# clear environment variable
unset WEB2PY_USE_DB_TESTING

0 comments on commit 9e88a76

Please sign in to comment.