Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
Add github test-action
Browse files Browse the repository at this point in the history
  • Loading branch information
valq7711 committed Aug 31, 2021
1 parent b68e356 commit a5d1c23
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/run_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: ombott-test

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt-get install memcached libmemcached-tools
python -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 -m pip install -r test-requirements.txt
python3 -m pip install ombott
- name: build
run: |
python3 setup.py install
- name: Test with pytest
run: |
python3 -m pytest --cov=py4web --cov-report html:cov.html -v -s tests/
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
pytest
pytest-cov
mechanize==0.4.5
python-memcached
26 changes: 14 additions & 12 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import os
import sys
import unittest
import tempfile
import time
import signal
from multiprocessing import Process
from unittest.mock import patch
from py4web.core import cli
from click.testing import CliRunner


def patched_cli():
def run_cli():
dirpath = tempfile.mkdtemp()
dir = os.path.join(dirpath, "apps")
testargs = ["py4web", 'setup', dir]
with patch.object(sys, "argv", testargs):
cli()
testargs = ["py4web", "run", "-d", "demo", dir]
with patch.object(sys, "argv", testargs):
cli()
runner = CliRunner()

testargs = ['setup', dir]
res = runner.invoke(cli, testargs, input='y')
if res.exception:
raise res.exception

testargs = ["run", "-d", "demo", dir]
res = runner.invoke(cli, testargs)
if res.exception:
raise res.exception


class MainTest(unittest.TestCase):
Expand All @@ -31,6 +33,6 @@ def handler(signum, frame):
signal.signal(signal.SIGALRM, handler)
signal.alarm(10)
try:
patched_cli()
run_cli()
except MyException:
pass

0 comments on commit a5d1c23

Please sign in to comment.