Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge ea0c10d into 8ba7faa
Browse files Browse the repository at this point in the history
  • Loading branch information
arnisoph committed May 28, 2016
2 parents 8ba7faa + ea0c10d commit be4a1ae
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 43 deletions.
58 changes: 58 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
image: docker:dind

stages:
- test
- deploy

.test_template: &test_template
script: |
export CONTAINER_CODE_IMAGE=tabellarius-code-$((((RANDOM + RANDOM) % 63001) + 2000))
echo -e "FROM ${DOCKER_IMAGE}\nCOPY . /code" > Dockerfile.tmp
if [ "${START_INTEGRATION_SERVERS}" = 'yes' ]; then
CID_IMAPSERVER=$(docker run -d -p 143 -p 993 -p 6379 -v /dev/random:/dev/random bechtoldt/tabellarius_tests-docker)
INTEGRATION_ADDR_IMAPSERVER=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' ${CID_IMAPSERVER})
echo -e "\nENV INTEGRATION_ADDR_IMAPSERVER=${INTEGRATION_ADDR_IMAPSERVER}" >> Dockerfile.tmp
fi
docker build --file=Dockerfile.tmp -t ${CONTAINER_CODE_IMAGE} .
docker run --rm -w /code ${CONTAINER_CODE_IMAGE} /bin/bash -c "pip install tox && tox -e ${TOX_ENV}"
find-tasks:
stage: test
variables:
DOCKER_IMAGE: python:latest
TOX_ENV: app_todo
<<: *test_template

check-code-style:
stage: test
variables:
DOCKER_IMAGE: python:latest
TOX_ENV: app_flake8
<<: *test_template

test-integration:py3.3:
stage: test
variables:
DOCKER_IMAGE: python:3.3
START_INTEGRATION_SERVERS: 'yes'
TOX_ENV: app_tests_min
<<: *test_template

test-integration:py3.4:
stage: test
variables:
DOCKER_IMAGE: python:3.4
START_INTEGRATION_SERVERS: 'yes'
TOX_ENV: app_tests_min
<<: *test_template

test-integration:py3.5:
stage: test
variables:
DOCKER_IMAGE: python:3.5
START_INTEGRATION_SERVERS: 'yes'
TOX_ENV: app_tests_min
<<: *test_template
42 changes: 30 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@ language: python

matrix:
include:
- python: '3.5'
env: TOX_ENV=app_tests_cov_upload
- python: '3.3'
env:
- TOX_ENV=app_tests_min
- START_INTEGRATION_SERVERS=yes
services:
- docker
- python: '3.4'
env: TOX_ENV=app_tests_min
services:
- docker
- python: '3.3'
env: TOX_ENV=app_tests_min
env:
- TOX_ENV=app_tests_min
- START_INTEGRATION_SERVERS=yes
services:
- docker
- python: '3.2'
env: TOX_ENV=app_tests_min
- python: '3.5'
env:
- TOX_ENV=app_tests_min
- START_INTEGRATION_SERVERS=yes
services:
- docker
- python: '3.5'
env: TOX_ENV=app_flake8
env:
- TOX_ENV=app_flake8
- python: '3.5'
env:
- TOX_ENV=tests_flake8
- python: '3.5'
env: TOX_ENV=tests_flake8
env:
- TOX_ENV=app_tests_cov_upload
- START_INTEGRATION_SERVERS=yes
services:
- docker
#- python: '3.5'
# env: TOX_ENV=app_todo
#- python: '3.5'
Expand All @@ -35,4 +45,12 @@ addons:
install:
- pip install tox
script:
- tox -e $TOX_ENV
- |
if [ "${START_INTEGRATION_SERVERS}" = 'yes' ]; then
CID_IMAPSERVER=$(docker run -d -p 10143:143 -p 10993:993 -p 6379:6379 -v /dev/random:/dev/random bechtoldt/tabellarius_tests-docker)
export INTEGRATION_PORT_IMAP=10143
export INTEGRATION_PORT_IMAPS=10993
export INTEGRATION_ADDR_IMAPSERVER=127.0.0.1
fi
tox -e ${TOX_ENV}
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,6 @@ If you prefer running Tabellarius on arbitrary computers you should consider usi
$ export WORKON_HOME=~/.virtualenvs/
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh
$ mkvirtualenv tabellarius-py32 --python=python3.2
$ mkvirtualenv tabellarius-py35 --python=python3.5
$ pip install tabellarius
$ python ${VIRTUAL_ENV}/lib/python3.2/site-packages/tabellarius/tabellarius.py --config=...
$ python ${VIRTUAL_ENV}/lib/python3.5/site-packages/tabellarius/tabellarius.py --config=...
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
'License :: OSI Approved :: Apache Software License',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down
10 changes: 7 additions & 3 deletions tests/integration/tabellarius_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def remove_imap_user(self, username='test'):

def create_basic_imap_object(self, username, password, starttls=False, imaps=True, test=None):
imapconn = imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=10993,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=self.INTEGRATION_PORT_IMAPS,
starttls=starttls,
imaps=imaps,
tlsverify=False, # TODO
Expand Down Expand Up @@ -86,8 +86,12 @@ def parse_message_files(self, directory='tests/mails/'):

return emails

INTEGRATION_ADDR_IMAPSERVER = os.getenv('INTEGRATION_ADDR_IMAPSERVER')
INTEGRATION_PORT_IMAP = os.getenv('INTEGRATION_PORT_IMAP', 143)
INTEGRATION_PORT_IMAPS = os.getenv('INTEGRATION_PORT_IMAPS', 993)
INTEGRATION_PORT_REDIS = os.getenv('INTEGRATION_PORT_REDIS', 6379)
logger = LoggerDummy()
rconn = redis.StrictRedis(host='127.0.0.1', port=6379)
rconn = redis.StrictRedis(host=INTEGRATION_ADDR_IMAPSERVER, port=INTEGRATION_PORT_REDIS)


if __name__ == "__main__":
Expand Down
32 changes: 16 additions & 16 deletions tests/integration/test_imap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def test_noop(self):
def test_connect_simple_plaintext(self):
username, password = self.create_imap_user()
self.assertEqual(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=10143,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=self.INTEGRATION_PORT_IMAP,
username=username,
password=password).connect(logout=True), (True, 'Logging out'))

Expand All @@ -30,8 +30,8 @@ def test_connect_error_auth_failed(self):

expect = '[AUTHENTICATIONFAILED] Authentication failed.'
self.assertEqual(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=10143,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=self.INTEGRATION_PORT_IMAP,
username=username,
password='wrongpassword').connect(logout=True), (False, expect))

Expand All @@ -44,8 +44,8 @@ def test_connect_manual_logout(self):
def test_connect_starttls(self):
username, password = self.create_imap_user()
self.assertEqual(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=10143,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=self.INTEGRATION_PORT_IMAP,
starttls=True,
imaps=False,
tlsverify=False, # TODO test tls verification?
Expand All @@ -55,8 +55,8 @@ def test_connect_starttls(self):
def test_connect_imaps(self):
username, password = self.create_imap_user()
self.assertEqual(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=10993,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=self.INTEGRATION_PORT_IMAPS,
starttls=False,
imaps=True,
tlsverify=False, # TODO test tls verification?
Expand All @@ -65,14 +65,14 @@ def test_connect_imaps(self):

def test_connect_error_refused(self):
username, password = self.create_imap_user()
self.assertTrue(imap.IMAP(logger=self.logger,
server='127.0.0.1',
port=1337,
starttls=False,
imaps=True,
tlsverify=False, # TODO test tls verification?
username=username,
password=password).connect(), (False, '] Connection refused'))
self.assertEqual(imap.IMAP(logger=self.logger,
server=self.INTEGRATION_ADDR_IMAPSERVER,
port=1337,
starttls=False,
imaps=True,
tlsverify=False, # TODO test tls verification?
username=username,
password=password).connect(), (False, '[Errno 111] Connection refused'))

def test_process_error(self):
try:
Expand Down
20 changes: 11 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ envlist = app_tests_min,app_flake8,tests_flake8
[testenv]
whitelist_externals = *
passenv = CI
DOCKER_TLS_VERIFY
DOCKER_HOST
DOCKER_CERT_PATH
DOCKER_HOST
DOCKER_IMAGE
DOCKER_MACHINE_NAME
DOCKER_TLS_VERIFY
INTEGRATION_ADDR_IMAPSERVER
INTEGRATION_PORT_IMAP
INTEGRATION_PORT_IMAPS
INTEGRATION_PORT_REDIS
TRAVIS_BUILD_ID
TRAVIS
TRAVIS_BRANCH
Expand All @@ -34,18 +39,15 @@ commands = grep -R TODO .

[testenv:app_tests_min]
deps = -rrequirements/test.txt
commands = docker run --name=tabellarius_test_dovecot -d -p 10143:143 -p 10993:993 -p 6379:6379 -v /dev/random:/dev/random bechtoldt/tabellarius_tests-docker
py.test -p no:cov --verbose tests/integration/
commands = py.test -p no:cov --verbose tests/integration/

[testenv:app_tests_cov]
deps = -rrequirements/test.txt
commands = docker run --name=tabellarius_test_dovecot -d -p 10143:143 -p 10993:993 -p 6379:6379 -v /dev/random:/dev/random bechtoldt/tabellarius_tests-docker
py.test --cov=tabellarius --verbose tests/integration/
commands = py.test --cov=tabellarius --verbose tests/integration/

[testenv:app_tests_cov_upload]
deps = -rrequirements/test.txt
commands = docker run --name=tabellarius_test_dovecot -d -p 10143:143 -p 10993:993 -p 6379:6379 -v /dev/random:/dev/random bechtoldt/tabellarius_tests-docker
py.test --cov=tabellarius --verbose tests/integration/
commands = py.test --cov=tabellarius --verbose tests/integration/
coveralls

[testenv:app_flake8]
Expand All @@ -56,4 +58,4 @@ commands = flake8 .
[testenv:app_todo]
changedir = tabellarius/
skipsdist = True
commands = grep -R TODO .
commands = grep -qR TODO . && false

0 comments on commit be4a1ae

Please sign in to comment.