Skip to content
This repository has been archived by the owner on Nov 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #281 from deltachat/pytest3
Browse files Browse the repository at this point in the history
next round of python bindings update
  • Loading branch information
hpk42 committed Sep 14, 2018
2 parents a65abba + 4e00d5a commit 0993064
Show file tree
Hide file tree
Showing 24 changed files with 1,672 additions and 51 deletions.
6 changes: 6 additions & 0 deletions python/CHANGELOG
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

0.5
---

- initial release with full low level C-API, and a first
high level API
9 changes: 5 additions & 4 deletions python/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Install
First you need to execute all the build steps to install the delta-core C-library,
see https://github.com/deltachat/deltachat-core/blob/master/README.md#build

Next, you need to do perform::
Presuming you have the delta-core library installed, you can then from the root of the repo::

cd python
pip install -e .

Afterwards you should be able to successfully import the bindings::
Expand All @@ -28,8 +29,8 @@ Afterwards you should be able to successfully import the bindings::
Running tests
-------------

Install the delta-core C-library (see _Install) and then
type the following to execute tests::
Install the delta-core C-library and the deltachat bindings (see _Install)
and then type the following to execute tests::

pip install tox
tox
Expand All @@ -38,7 +39,7 @@ If you want to run functional tests that run against real
e-mail accounts, generate a "liveconfig" file where each
lines contains account settings, for example::

# liveconfig file for specifying real-life accounts
# 'liveconfig' file specifying imap/smtp accounts
addr=some-email@example.org mail_pw=password
addr=other-email@example.org mail_pw=otherpassword

Expand Down
19 changes: 12 additions & 7 deletions python/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import re
import threading
from deltachat import Account
from deltachat.types import cached_property


def pytest_addoption(parser):
Expand All @@ -15,21 +16,23 @@ def pytest_addoption(parser):
@pytest.fixture
def acfactory(pytestconfig, tmpdir, request):
fn = pytestconfig.getoption("--liveconfig")
if not fn:
pytest.skip("specify a --liveconfig file to run tests with real accounts")

class AccountMaker:
def __init__(self):
self.configlist = []
self.live_count = 0
self.offline_count = 0

@cached_property
def configlist (self):
configlist = []
for line in open(fn):
if line.strip():
d = {}
for part in line.split():
name, value = part.split("=")
d[name] = value
self.configlist.append(d)
self.live_count = 0
self.offline_count = 0
configlist.append(d)
return configlist

def get_offline_account(self):
self.offline_count += 1
Expand All @@ -39,11 +42,13 @@ def get_offline_account(self):
return ac

def get_live_account(self, started=True):
if not fn:
pytest.skip("specify a --liveconfig file to run tests with real accounts")
self.live_count += 1
configdict = self.configlist.pop(0)
tmpdb = tmpdir.join("livedb%d" % self.live_count)
ac = Account(tmpdb.strpath, logid="ac{}".format(self.live_count))
ac._evlogger.set_timeout(10)
ac._evlogger.set_timeout(20)
ac.set_config(**configdict)
if started:
ac.start()
Expand Down
241 changes: 241 additions & 0 deletions python/doc/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
# Makefile for Sphinx documentation
#

VERSION = $(shell python -c "import conf ; print(conf.version)")
DOCZIP = devpi-$(VERSION).doc.zip
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = _build

export HOME=/tmp/home
export TESTHOME=$(HOME)

# Internal variables.
PAPEROPT_a4 = -D latex_paper_size=a4
PAPEROPT_letter = -D latex_paper_size=letter
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
# the i18n builder cannot share the environment and doctrees with the others
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .

# This variable is not auto generated as the order is important.
USER_MAN_CHAPTERS = commands\
user\
indices\
packages\
# userman/index.rst\
# userman/devpi_misc.rst\
# userman/devpi_concepts.rst\

#export DEVPI_CLIENTDIR=$(CURDIR)/.tmp_devpi_user_man/client
#export DEVPI_SERVERDIR=$(CURDIR)/.tmp_devpi_user_man/server

chapter = commands

.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp \
epub latex latexpdf text man changes linkcheck doctest gettext install \
quickstart-releaseprocess quickstart-pypimirror quickstart-server regen \
prepare-quickstart\
regen.server-fresh regen.server-restart regen.server-clean\
regen.uman-all regen.uman

help:
@echo "Please use \`make <target>' where <target> is one of"
@echo " html to make standalone HTML files"
@echo " dirhtml to make HTML files named index.html in directories"
@echo " singlehtml to make a single large HTML file"
@echo " pickle to make pickle files"
@echo " json to make JSON files"
@echo " htmlhelp to make HTML files and a HTML help project"
@echo " qthelp to make HTML files and a qthelp project"
@echo " devhelp to make HTML files and a Devhelp project"
@echo " epub to make an epub"
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
@echo " latexpdf to make LaTeX files and run them through pdflatex"
@echo " text to make text files"
@echo " man to make manual pages"
@echo " texinfo to make Texinfo files"
@echo " info to make Texinfo files and run them through makeinfo"
@echo " gettext to make PO message catalogs"
@echo " changes to make an overview of all changed/added/deprecated items"
@echo " linkcheck to check all external links for integrity"
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
@echo
@echo "User Manual Regen Targets"
@echo " regen.uman regenerates page. of the user manual chapeter e.g. regen.uman chapter=..."
@echo " regen.uman-all regenerates the user manual"
@echo " regen.uman-clean stop temp server and clean up directory"
@echo " Chapter List: $(USER_MAN_CHAPTERS)"

clean:
-rm -rf $(BUILDDIR)/*

version:
@echo "version $(VERSION)"

doczip: html
python doczip.py $(DOCZIP) _build/html

html:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."

dirhtml:
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
@echo
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."

singlehtml:
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
@echo
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."

pickle:
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
@echo
@echo "Build finished; now you can process the pickle files."

json:
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
@echo
@echo "Build finished; now you can process the JSON files."

htmlhelp:
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
@echo
@echo "Build finished; now you can run HTML Help Workshop with the" \
".hhp project file in $(BUILDDIR)/htmlhelp."

qthelp:
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
@echo
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/devpi.qhcp"
@echo "To view the help file:"
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/devpi.qhc"

devhelp:
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
@echo
@echo "Build finished."
@echo "To view the help file:"
@echo "# mkdir -p $$HOME/.local/share/devhelp/devpi"
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/devpi"
@echo "# devhelp"

epub:
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
@echo
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."

latex:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
@echo "Run \`make' in that directory to run these through (pdf)latex" \
"(use \`make latexpdf' here to do that automatically)."

latexpdf:
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
@echo "Running LaTeX files through pdflatex..."
$(MAKE) -C $(BUILDDIR)/latex all-pdf
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."

text:
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
@echo
@echo "Build finished. The text files are in $(BUILDDIR)/text."

man:
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
@echo
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."

texinfo:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
@echo "Run \`make' in that directory to run these through makeinfo" \
"(use \`make info' here to do that automatically)."

info:
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
@echo "Running Texinfo files through makeinfo..."
make -C $(BUILDDIR)/texinfo info
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."

gettext:
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
@echo
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."

changes:
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
@echo
@echo "The overview file is in $(BUILDDIR)/changes."

linkcheck:
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
@echo
@echo "Link check complete; look for any errors in the above output " \
"or in $(BUILDDIR)/linkcheck/output.txt."

doctest:
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
@echo "Testing of doctests in the sources finished, look at the " \
"results in $(BUILDDIR)/doctest/output.txt."


regen: quickstart-pypimirror quickstart-releaseprocess quickstart-server
rm -rf TARGETDIR

quickstart-pypimirror:
USER=testuser sh regen.sh --update quickstart-pypimirror.rst

quickstart-releaseprocess:
USER=testuser sh regen.sh --update quickstart-releaseprocess.rst

quickstart-server:
USER=testuser sh regen.sh --update quickstart-server.rst


# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# USER MANUAL TARGETS


$(USER_MAN_CHAPTERS):
@echo Regenerating $@
USER=testuser python regendoc.py --update userman/devpi_$@.rst

regen.sample_undo:
-hg revert --all ./userman/pysober

regen.server-fresh: regen.server-clean
devpi-server --start --serverdir=$(TESTHOME)/.devpi/server --init

regen.server-restart:
-devpi-server --stop --serverdir=$(TESTHOME)/.devpi/server
devpi-server --start --serverdir=$(TESTHOME)/.devpi/server

regen.server-clean: regen.sample_undo
@echo stopping server
-devpi-server --stop --serverdir=$(TESTHOME)/.devpi/server
@echo deleting $(TESTHOME)/.devpi state
-rm -rf $(TESTHOME)/.devpi
@echo deleting pysober/dist
-rm -rf userman/pysober/dist
hg revert --all userman/pysober



regen.uman-all : regen.server-fresh $(USER_MAN_CHAPTERS)
hg revert --all userman/pysober
rm -rf userman/pysober/dist

regen.uman: regen.server-restart $(chapter)


0 comments on commit 0993064

Please sign in to comment.