Commit a57b220a authored by Daniel Widerin's avatar Daniel Widerin

initial commit

parents
/bin
/include
/lib
/.Python
/pip-selfcheck.json
/__pycache__
/.cache
variables:
DOCKER_TAG: "registry.gitlab.com/widerin/vlbg-webdev-1016"
stages:
- build
- test
- deploy
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
build:
tags:
- dind
image: docker:latest
variables:
CONTAINER_BUILD_IMAGE: ${DOCKER_TAG}:latest
script:
- docker build -t $CONTAINER_BUILD_IMAGE -f docker/Dockerfile .
- docker push $CONTAINER_BUILD_IMAGE
test:
tags:
- dind
stage: test
variables:
CONTAINER_TEST_IMAGE: ${DOCKER_TAG}:latest
script:
- docker pull $CONTAINER_TEST_IMAGE
- docker run $CONTAINER_TEST_IMAGE pytest
# VLBG WEBDEV Oct. 2016
Sample pyramid application dockerized
FROM python:3-alpine
COPY ["requirements.txt", "server.py", "tests.py", "/app/"]
RUN pip install --no-cache-dir -r /app/requirements.txt
CMD ["python", "/app/server.py" ]
[pytest]
norecursedirs = include lib
testpaths = tests.py
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello %(name)s!' % request.matchdict)
if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '/hello/{name}')
config.add_view(hello_world, route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
import unittest
from pyramid import testing
class TutorialViewTests(unittest.TestCase):
def setUp(self):
self.config = testing.setUp()
def tearDown(self):
testing.tearDown()
def test_hello_world(self):
from server import hello_world
request = testing.DummyRequest(path='/hello/daniel')
response = hello_world(request)
self.assertEqual(response.status_code, 200)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment