Add tests for argos boot

This commit is contained in:
Vincent Emonet 2021-02-09 15:21:53 +01:00
parent 9fe75094e0
commit d53e08b57e
3 changed files with 87 additions and 26 deletions

View file

@ -8,35 +8,39 @@ on:
jobs:
# tests:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: [3.6, 3.7, 3.8]
# 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: |
# python -m pip install --upgrade pip
# pip install flake8 pytest
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
# - name: Lint with flake8
# run: |
# # stop the build if there are Python syntax errors or undefined names
# flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
# - name: Test with pytest
# run: |
# python setup.py pytest
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Check code style with flake8 (lint)
run: |
# warnings if there are Python syntax errors or undefined names
# (remove --exit-zero to fail when syntax error)
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
- name: Test with pytest
run: pytest
publish:
# needs: [ tests ]
needs: [ tests ]
runs-on: ubuntu-latest
steps:

44
.github/workflows/run-tests.yml vendored Normal file
View file

@ -0,0 +1,44 @@
name: Run tests
# Run test at each push to main, if changes to package or tests files
on:
workflow_dispatch:
push:
branches: [ main ]
paths:
- 'requirements.txt'
- 'app/**'
- 'tests/**'
- '.github/workflows/run-tests.yml'
jobs:
tests:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Check code style with flake8 (lint)
run: |
# warnings if there are Python syntax errors or undefined names
# (remove --exit-zero to fail when syntax error)
flake8 . --count --exit-zero --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
- name: Test with pytest
run: pytest

13
tests/test_init.py Normal file
View file

@ -0,0 +1,13 @@
import pytest
from app.init import boot
from argostranslate import package
def test_boot_argos():
"""Test Argos translate models initialization"""
boot()
print(package.get_installed_packages())
assert len(package.get_installed_packages()) > 2
# Check length models?
# assert 0.80 < scores['precision'] < 0.95