added tests

test

test

add jenkinsfile

test

test

change to jenkinsfile

fix to jenkinsfile

asd

asd

asd

asd

asd
This commit is contained in:
wangobango 2021-11-30 16:13:45 +01:00
parent 7f26747f09
commit 1dc93c5f0d
10 changed files with 86 additions and 4 deletions

4
.gitignore vendored
View File

@ -1,2 +1,6 @@
__pycache__/* __pycache__/*
venv/* venv/*
*.egg-info
__pycache__
.pytest_cache
something/*

View File

@ -1,12 +1,12 @@
FROM python:3 FROM python:3
ENV DOCKER_APP True ENV DOCKER_APP True
USER root
WORKDIR /app WORKDIR /app
RUN git clone https://git.wmi.amu.edu.pl/s415366/pbr-ayct-core
COPY . . COPY . .
RUN chmod u+x setup_core.sh RUN chmod u+x setup_core.sh
RUN bash setup_core.sh RUN bash setup_core.sh
RUN pip3 install -r requirements.txt RUN pip3 install -r requirements.txt
EXPOSE 5000/udp EXPOSE 5000/udp
EXPOSE 5000/tcp EXPOSE 5000/tcp
CMD ["python3", "app.py"] CMD ["python3", "ayct-backend/app.py"]

22
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,22 @@
pipeline {
agent {
docker {
image 'python:latest'
args '-u root --privileged'
}
}
stages {
stage('build') {
steps {
sh 'bash setup_core.sh'
sh 'pip install -r requirements.txt'
sh 'pip install --user -e .'
}
}
stage('test') {
steps {
sh 'pytest'
}
}
}
}

0
ayct-backend/__init__.py Normal file
View File

View File

@ -12,6 +12,9 @@ class Hello(Resource):
api.add_resource(Hello, "/hello") api.add_resource(Hello, "/hello")
def create_app():
return app
if __name__ == "__main__": if __name__ == "__main__":
port = int(os.environ.get('PORT', 5000)) port = int(os.environ.get('PORT', 5000))
app.run(host = '0.0.0.0', port = port) app.run(host = '0.0.0.0', port = port)

View File

@ -0,0 +1,20 @@
import os
import tempfile
import pytest
from app import create_app
@pytest.fixture
def client():
app = create_app()
app.run(host = '0.0.0.0', port = 5000)
with app.test_client() as client:
with app.app_context():
pass
yield client
def test_first_endpoint(client):
rv = client.get("/hello")
assert b'All You Can Tweet' in rv.data

7
pyproject.toml Normal file
View File

@ -0,0 +1,7 @@
[build-system]
requires = [
"setuptools>=42",
"wheel",
"flask"
]
build-backend = "setuptools.build_meta"

View File

@ -1,2 +1,3 @@
Flask==2.0.2 Flask==2.0.2
Flask-RESTful==0.3.9 flask_restful==0.3.9
pytest==6.2.5

24
setup.cfg Normal file
View File

@ -0,0 +1,24 @@
[metadata]
name = pbrAyctBackend
version = 0.0.1
author = Łukasz Ramon Piotrek
author_email = ramon.dyzman@gmail.com
description = A small example package
long_description = file: readme.md
long_description_content_type = text/markdown
url = https://git.wmi.amu.edu.pl/s434708/pbr-ayct-backend
project_urls =
Bug Tracker = https://github.com/pypa/sampleproject/issues
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: MIT License
Operating System :: OS Independent
[options]
package_dir =
= ayct-backend
packages = find:
python_requires = >=3.6
[options.packages.find]
where = src

View File

@ -1,3 +1,4 @@
git clone https://git.wmi.amu.edu.pl/s415366/pbr-ayct-core
cd pbr-ayct-core cd pbr-ayct-core
pip3 install setuptools pip3 install setuptools
python3 -m pip install --upgrade build python3 -m pip install --upgrade build