Merge pull request #62 from ankicommunity/feature/run-unittests
Fix and run unittests
This commit is contained in:
commit
bd5f002718
12
Makefile
12
Makefile
@ -3,8 +3,8 @@
|
||||
ANKI_SERVER_NAME ?= "Anki Sync Server"
|
||||
ANKI_SERVER_VERSION ?= "v0.1.0"
|
||||
ANKI_SERVER_DESCRIPTION ?= "Self-hosted Anki Sync Server."
|
||||
ENV ?= local
|
||||
|
||||
ENV ?= local
|
||||
-include config/.env.${ENV}
|
||||
export
|
||||
|
||||
@ -17,10 +17,18 @@ help:
|
||||
docs: print-env
|
||||
@${MKDOCS} ${MKDOCS_OPTION} -f docs/mkdocs.yml
|
||||
|
||||
.PHONY: tests #: Run unit tests.
|
||||
tests:
|
||||
@${UNITTEST} discover -s tests
|
||||
|
||||
.PHONY: notebooks #: Run jupyter notebooks.
|
||||
notebooks:
|
||||
@${JUPYTER} ${JUPYTER_OPTION}
|
||||
|
||||
%:
|
||||
@test -f scripts/${*}.sh
|
||||
@${SHELL} scripts/${*}.sh
|
||||
@${SHELL} scripts/${*}.sh
|
||||
|
||||
.PHONY: init #: Download Python dependencies.
|
||||
init:
|
||||
@${POETRY} install
|
||||
37
README.md
37
README.md
@ -26,9 +26,11 @@ It supports Python 3 and Anki 2.1.
|
||||
- [Installing](#installing)
|
||||
- [Installing (Docker)](#installing-docker)
|
||||
- [Setting up Anki](#setting-up-anki)
|
||||
- [Anki 2.1](#anki-21)
|
||||
- [Anki 2.0](#anki-20)
|
||||
- [AnkiDroid](#ankidroid)
|
||||
- [Anki 2.1](#anki-21)
|
||||
- [Anki 2.0](#anki-20)
|
||||
- [AnkiDroid](#ankidroid)
|
||||
- [Development](#development)
|
||||
- [Testing](#testing)
|
||||
- [ENVVAR configuration overrides](#envvar-configuration-overrides)
|
||||
- [Support for other database backends](#support-for-other-database-backends)
|
||||
</details>
|
||||
@ -142,6 +144,35 @@ Even though the AnkiDroid interface will request an email address, this is not
|
||||
required; it will simply be the username you configured with `ankisyncctl.py
|
||||
adduser`.
|
||||
|
||||
Development
|
||||
-----------
|
||||
|
||||
### Testing
|
||||
|
||||
0. Prerequites
|
||||
|
||||
This project uses [GNU Make](https://www.gnu.org/software/make/) to simplify the development commands. It also uses [Poetry](https://python-poetry.org/) to manage the Python dependencies. Ensure they are installed.
|
||||
|
||||
1. Create a config for your local environment.
|
||||
|
||||
```bash
|
||||
$ cp config/.env.example config/.env.local
|
||||
```
|
||||
|
||||
See [ENVVAR configuration overrides](#envvar-configuration-overrides) for more information.
|
||||
|
||||
2. Download Python dependencies.
|
||||
|
||||
```bash
|
||||
$ make init
|
||||
```
|
||||
|
||||
3. Run unit tests.
|
||||
|
||||
```bash
|
||||
$ make tests
|
||||
```
|
||||
|
||||
ENVVAR configuration overrides
|
||||
------------------------------
|
||||
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
# .env.example (anki-sync-server)
|
||||
|
||||
## Make
|
||||
MKDOCS=mkdocs
|
||||
JUPYTER=jupyter
|
||||
POETRY=poetry
|
||||
MKDOCS=poetry run mkdocs
|
||||
JUPYTER=poetry run jupyter
|
||||
UNITTEST=poetry run python -m unittest
|
||||
|
||||
## Ankisyncd
|
||||
ANKISYNCD_HOST=0.0.0.0
|
||||
@ -13,10 +15,10 @@ ANKISYNCD_BASE_MEDIA_URL=/msync/
|
||||
ANKISYNCD_AUTH_DB_PATH=./auth.db
|
||||
ANKISYNCD_SESSION_DB_PATH=./session.db
|
||||
|
||||
ANKISYNCD_FULL_SYNC_MANAGER
|
||||
ANKISYNCD_SESSION_MANAGER
|
||||
ANKISYNCD_USER_MANAGER
|
||||
ANKISYNCD_COLLECTION_WRAPPER
|
||||
# ANKISYNCD_FULL_SYNC_MANAGER
|
||||
# ANKISYNCD_SESSION_MANAGER
|
||||
# ANKISYNCD_USER_MANAGER
|
||||
# ANKISYNCD_COLLECTION_WRAPPER
|
||||
|
||||
## Mkdocs
|
||||
MKDOCS_OPTION=serve
|
||||
@ -25,4 +27,4 @@ MKDOCS_OPTION=serve
|
||||
JUPYTER_OPTION=lab
|
||||
|
||||
## Path
|
||||
PATH:=.venv/bin/path:${PATH}
|
||||
PATH:=.venv/bin:${PATH}
|
||||
51
poetry.lock
generated
51
poetry.lock
generated
@ -612,7 +612,7 @@ twitter = ["twython"]
|
||||
|
||||
[[package]]
|
||||
name = "notebook"
|
||||
version = "6.1.5"
|
||||
version = "6.1.6"
|
||||
description = "A web-based notebook environment for interactive computing"
|
||||
category = "dev"
|
||||
optional = false
|
||||
@ -635,8 +635,9 @@ tornado = ">=5.0"
|
||||
traitlets = ">=4.2.1"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx", "nbsphinx", "sphinxcontrib-github-alt"]
|
||||
test = ["nose", "coverage", "requests", "nose-warnings-filters", "nbval", "nose-exclude", "selenium", "pytest", "pytest-cov", "requests-unixsocket"]
|
||||
docs = ["sphinx", "nbsphinx", "sphinxcontrib-github-alt", "sphinx-rtd-theme"]
|
||||
json-logging = ["json-logging"]
|
||||
test = ["pytest", "coverage", "requests", "nbval", "selenium", "pytest-cov", "requests-unixsocket"]
|
||||
|
||||
[[package]]
|
||||
name = "orjson"
|
||||
@ -1001,6 +1002,18 @@ brotli = ["brotlipy (>=0.6.0)"]
|
||||
secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"]
|
||||
socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "waitress"
|
||||
version = "1.4.4"
|
||||
description = "Waitress WSGI server"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["Sphinx (>=1.8.1)", "docutils", "pylons-sphinx-themes (>=1.0.9)"]
|
||||
testing = ["pytest", "pytest-cover", "coverage (>=5.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "wcwidth"
|
||||
version = "0.2.5"
|
||||
@ -1029,6 +1042,24 @@ python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*"
|
||||
docs = ["Sphinx (>=1.7.5)", "pylons-sphinx-themes"]
|
||||
testing = ["pytest (>=3.1.0)", "coverage", "pytest-cov", "pytest-xdist"]
|
||||
|
||||
[[package]]
|
||||
name = "webtest"
|
||||
version = "2.0.35"
|
||||
description = "Helper to test WSGI applications"
|
||||
category = "dev"
|
||||
optional = false
|
||||
python-versions = "*"
|
||||
|
||||
[package.dependencies]
|
||||
beautifulsoup4 = "*"
|
||||
six = "*"
|
||||
waitress = ">=0.8.5"
|
||||
WebOb = ">=1.2"
|
||||
|
||||
[package.extras]
|
||||
docs = ["Sphinx (>=1.8.1)", "docutils", "pylons-sphinx-themes (>=1.0.8)"]
|
||||
tests = ["nose (<1.3.0)", "coverage", "mock", "pastedeploy", "wsgiproxy2", "pyquery"]
|
||||
|
||||
[[package]]
|
||||
name = "widgetsnbextension"
|
||||
version = "3.5.1"
|
||||
@ -1043,7 +1074,7 @@ notebook = ">=4.4.1"
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = "^3.8"
|
||||
content-hash = "4652673e61d57bf6f9a67c42f717aa0d014e0073a274183a8d47e65e0c251ffa"
|
||||
content-hash = "6672edcfd7abe5be006c66fefed7f00b286aa8233a28c0b2f5d42b5328d7f0d8"
|
||||
|
||||
[metadata.files]
|
||||
anki = [
|
||||
@ -1305,8 +1336,8 @@ nltk = [
|
||||
{file = "nltk-3.5.zip", hash = "sha256:845365449cd8c5f9731f7cb9f8bd6fd0767553b9d53af9eb1b3abf7700936b35"},
|
||||
]
|
||||
notebook = [
|
||||
{file = "notebook-6.1.5-py3-none-any.whl", hash = "sha256:508cf9dad7cdb3188f1aa27017dc78179029dfe83814fc505329f689bc2ab50f"},
|
||||
{file = "notebook-6.1.5.tar.gz", hash = "sha256:3db37ae834c5f3b6378381229d0e5dfcbfb558d08c8ce646b1ad355147f5e91d"},
|
||||
{file = "notebook-6.1.6-py3-none-any.whl", hash = "sha256:e6a62188e319a5d45dd2ed24719f646adf88bef8be1f654ebd0ab360ece6d7a6"},
|
||||
{file = "notebook-6.1.6.tar.gz", hash = "sha256:cf40d4f81541401db5a2fda1707ca7877157abd41f04ef7b88f02b67f3c61791"},
|
||||
]
|
||||
orjson = [
|
||||
{file = "orjson-3.4.6-cp36-cp36m-macosx_10_7_x86_64.whl", hash = "sha256:4e258f4696255de8038fd01ead8277a7c5c6d1e453cc7ca5aad8c1e9f74af62e"},
|
||||
@ -1645,6 +1676,10 @@ urllib3 = [
|
||||
{file = "urllib3-1.26.2-py2.py3-none-any.whl", hash = "sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473"},
|
||||
{file = "urllib3-1.26.2.tar.gz", hash = "sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08"},
|
||||
]
|
||||
waitress = [
|
||||
{file = "waitress-1.4.4-py2.py3-none-any.whl", hash = "sha256:3d633e78149eb83b60a07dfabb35579c29aac2d24bb803c18b26fb2ab1a584db"},
|
||||
{file = "waitress-1.4.4.tar.gz", hash = "sha256:1bb436508a7487ac6cb097ae7a7fe5413aefca610550baf58f0940e51ecfb261"},
|
||||
]
|
||||
wcwidth = [
|
||||
{file = "wcwidth-0.2.5-py2.py3-none-any.whl", hash = "sha256:beb4802a9cebb9144e99086eff703a642a13d6a0052920003a230f3294bbe784"},
|
||||
{file = "wcwidth-0.2.5.tar.gz", hash = "sha256:c4d647b99872929fdb7bdcaa4fbe7f01413ed3d98077df798530e5b04f116c83"},
|
||||
@ -1657,6 +1692,10 @@ webob = [
|
||||
{file = "WebOb-1.8.6-py2.py3-none-any.whl", hash = "sha256:a3c89a8e9ba0aeb17382836cdb73c516d0ecf6630ec40ec28288f3ed459ce87b"},
|
||||
{file = "WebOb-1.8.6.tar.gz", hash = "sha256:aa3a917ed752ba3e0b242234b2a373f9c4e2a75d35291dcbe977649bd21fd108"},
|
||||
]
|
||||
webtest = [
|
||||
{file = "WebTest-2.0.35-py2.py3-none-any.whl", hash = "sha256:44ddfe99b5eca4cf07675e7222c81dd624d22f9a26035d2b93dc8862dc1153c6"},
|
||||
{file = "WebTest-2.0.35.tar.gz", hash = "sha256:aac168b5b2b4f200af4e35867cf316712210e3d5db81c1cbdff38722647bb087"},
|
||||
]
|
||||
widgetsnbextension = [
|
||||
{file = "widgetsnbextension-3.5.1-py2.py3-none-any.whl", hash = "sha256:bd314f8ceb488571a5ffea6cc5b9fc6cba0adaf88a9d2386b93a489751938bcd"},
|
||||
{file = "widgetsnbextension-3.5.1.tar.gz", hash = "sha256:079f87d87270bce047512400efd70238820751a11d2d8cb137a5a5bdbaf255c7"},
|
||||
|
||||
@ -3,6 +3,9 @@ name = "anki-sync-server"
|
||||
version = "2.2.0"
|
||||
description = "Self-hosted Anki Sync Server."
|
||||
authors = ["Vikash Kothary <kothary.vikash@gmail.com>"]
|
||||
packages = [
|
||||
{ include = "ankisyncd", from = "src" }
|
||||
]
|
||||
|
||||
[tool.poetry.dependencies]
|
||||
python = "^3.8"
|
||||
@ -21,6 +24,7 @@ webob = "^1.8.6"
|
||||
mkdocs = "^1.1.2"
|
||||
jupyter = "^1.0.0"
|
||||
jupyterlab = "^2.2.2"
|
||||
webtest = "^2.0.35"
|
||||
|
||||
[build-system]
|
||||
requires = ["poetry>=0.12"]
|
||||
|
||||
@ -47,7 +47,7 @@ nbconvert==6.0.7; python_version >= "3.6"
|
||||
nbformat==5.0.8; python_version >= "3.6"
|
||||
nest-asyncio==1.4.3; python_version >= "3.6"
|
||||
nltk==3.5; python_version >= "3.5"
|
||||
notebook==6.1.5; python_version >= "3.5"
|
||||
notebook==6.1.6; python_version >= "3.5"
|
||||
orjson==3.4.6; python_version >= "3.8"
|
||||
packaging==20.8; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
|
||||
pandocfilters==1.4.3; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.4.0" and python_version >= "3.6"
|
||||
@ -84,8 +84,10 @@ tornado==6.1; python_version >= "3.6"
|
||||
tqdm==4.54.1; python_version >= "3.5" and python_full_version < "3.0.0" or python_version >= "3.5" and python_full_version >= "3.4.0"
|
||||
traitlets==5.0.5; python_version >= "3.7"
|
||||
urllib3==1.26.2; python_version >= "3.8" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version < "4" and python_version >= "3.8"
|
||||
waitress==1.4.4; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
|
||||
wcwidth==0.2.5; python_full_version >= "3.6.1" and python_version >= "3.6"
|
||||
webencodings==0.5.1; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
|
||||
webob==1.8.6; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.3.0")
|
||||
webtest==2.0.35
|
||||
widgetsnbextension==3.5.1
|
||||
-e src/.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user