1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00

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