summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvarac <varacanero@zeromail.org>2017-02-02 11:54:28 +0100
committervarac <varacanero@zeromail.org>2017-02-02 11:56:32 +0100
commit3a414d801a728516c68e1f3ff18c6c51286fd674 (patch)
tree49157a0b82af34aa3715b1d33e24b4051760deb4
parent08ecab8e481086f46e300795d88779454b83883d (diff)
parent28936b276cc2fa8f3572c9248ed4bc5bef4ea7c4 (diff)
Merge branch 'master' into debian/platform-0.10
-rw-r--r--.gitignore3
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--README.md14
-rw-r--r--pkg/requirements-testing.pip6
-rw-r--r--setup.cfg20
-rw-r--r--src/leap/mx/mail_receiver.py16
-rw-r--r--tox.ini14
7 files changed, 66 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index d1590bf..114fc4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -25,9 +25,10 @@ PKG-INFO
pip-log.txt
# Unit test / coverage reports
+docs/cov_html/
.coverage
.tox
-nosetests.xml
+.cache
# Translations
*.mo
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index edb90be..2f087c0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,8 +1,8 @@
stages:
+ #- test
- package
- test_package
-
.job_template: &job_definition
stage: package
image: "0xacab.org:4567/leap/gitlab-buildpackage:build_${DIST}_${ARCH}"
@@ -20,7 +20,7 @@ stages:
# image: leapcode/soledad:latest
# stage: test
# script:
-# - tox --recreate
+# - tox --recreate
package:amd64:jessie:
variables:
diff --git a/README.md b/README.md
index c78b14b..cd55f6d 100644
--- a/README.md
+++ b/README.md
@@ -51,6 +51,20 @@ Please use that for bug reports and feature requests instead of github's
tracker. We're using github for code commenting and review between
collaborators.
+### Running Tests
+
+You need tox to run the tests. If you don't have it in your system yet::
+
+~~~
+$ pip install tox
+~~~
+
+And then run all the tests::
+
+~~~
+$ tox
+~~~
+
## Issues
* see the [Changelog](./CHANGELOG) for details of all major changes in the different versions
diff --git a/pkg/requirements-testing.pip b/pkg/requirements-testing.pip
index 94b8e9c..322f1e8 100644
--- a/pkg/requirements-testing.pip
+++ b/pkg/requirements-testing.pip
@@ -1,2 +1,8 @@
pep8
+flake8
+coverage
+pytest
+pytest-pep8
+pytest-cov
+pytest-pdb
setuptools-trial
diff --git a/setup.cfg b/setup.cfg
index d8a5cc1..b58cc41 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,9 +1,6 @@
-[aliases]
-test = trial
-
[pep8]
exclude = versioneer.py,_version.py,*.egg,build,dist,docs
-ignore = E731
+ignore = E731 E402
[flake8]
exclude = versioneer.py,_version.py,*.egg,build,dist,docs
@@ -15,3 +12,18 @@ style = pep440
versionfile_source = src/leap/mx/_version.py
versionfile_build = leap/mx/_version.py
tag_prefix =
+
+[tool:pytest]
+pep8ignore =
+ * E731 E402
+ docs/conf.py ALL
+ versioneer.py ALL
+ _version.py ALL
+ *.egg ALL
+ *_rc.py ALL
+
+[coverage:run]
+branch = True
+
+[coverage:html]
+directory = doc/cov_html
diff --git a/src/leap/mx/mail_receiver.py b/src/leap/mx/mail_receiver.py
index 7c5a368..b200772 100644
--- a/src/leap/mx/mail_receiver.py
+++ b/src/leap/mx/mail_receiver.py
@@ -202,14 +202,22 @@ class MailReceiver(Service):
with openpgp.TempGPGWrapper(gpgbinary='/usr/bin/gpg') as gpg:
gpg.import_keys(pubkey)
key = gpg.list_keys().pop()
+
+ encryption_result = gpg.encrypt(
+ json.dumps(data, ensure_ascii=False),
+ key["fingerprint"],
+ symmetric=False)
+
+ if not encryption_result.ok:
+ log.msg("_encrypt_message: Encryption failed with status: %r"
+ % (encryption_result.status,))
+ return None
+
doc.content = {
self.INCOMING_KEY: True,
self.ERROR_DECRYPTING_KEY: False,
ENC_SCHEME_KEY: EncryptionSchemes.PUBKEY,
- ENC_JSON_KEY: str(gpg.encrypt(
- json.dumps(data, ensure_ascii=False),
- key["fingerprint"],
- symmetric=False))
+ ENC_JSON_KEY: str(encryption_result)
}
return doc
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..417bd18
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,14 @@
+[tox]
+envlist = py27
+skipsdist=True
+
+[testenv]
+commands = py.test --cov-report=html \
+ --cov-report=term \
+ --cov=leap.mx \
+ --pep8 {posargs}
+usedevelop = True
+deps =
+ -r{toxinidir}/pkg/requirements-testing.pip
+setenv =
+ HOME=/tmp