forked from kompetenzinventar/ki-backend
Compare commits
94 Commits
Author | SHA1 | Date | |
---|---|---|---|
3d271cdf7b | |||
f4c54526d1 | |||
e9236f7e19 | |||
f04120fdc0 | |||
1f87e2d96e | |||
c5a38dca81 | |||
6424af8b3f | |||
184b1c33eb | |||
5f27eaa9a1 | |||
862bd9f7a3 | |||
8478e8d76e | |||
b0652add43 | |||
60c906cb5c | |||
2ff958c55f | |||
146eb995a8 | |||
33187428cf | |||
06caf796cd | |||
54326129e4 | |||
32bb81b69b | |||
fc8a06e562 | |||
b8b713c620 | |||
186ab9af43 | |||
0d77c8d637 | |||
72fda5df51 | |||
739ce0382b | |||
4c345ecc5f | |||
5882eeaf2e | |||
0512bc0dc3 | |||
319bf9b2f5 | |||
717454e205 | |||
496550a959 | |||
7ebf13edf3 | |||
5409bdeaee | |||
4064a65e63 | |||
afe22e13c1 | |||
e4d0a89053 | |||
78bdd796e0 | |||
c9f83e80b3 | |||
5369de67d8 | |||
54c5246f0a | |||
9a95baf106 | |||
338380ed93 | |||
3d128d771c | |||
6b7517fc7a | |||
5ceb361da3 | |||
4379a06f26 | |||
c43f375e4b | |||
621a90b8ab | |||
033dee7836 | |||
ca81e8bf70 | |||
d507a20a93 | |||
3f2c23c386 | |||
b46ac5e379 | |||
fa4429b6ef | |||
7a0f2434db | |||
8c3fe3fe7d | |||
56ade6de68 | |||
28cf714217 | |||
9ff56f6676 | |||
2412df4960 | |||
469ef511d6 | |||
47d2c94b79 | |||
384dd82454 | |||
b0dcfacd25 | |||
86edb246bf | |||
9424e21edc | |||
f02efab07a | |||
08f1104942 | |||
8dde142f38 | |||
d1b1636aa2 | |||
3fcd1fa20e | |||
8394400e96 | |||
843050f923 | |||
812913ffe2 | |||
dee80c7e14 | |||
de60ec0d46 | |||
6c6fcea81c | |||
166e0d40c6 | |||
c9b5ab62ed | |||
c0005100b4 | |||
d614039cdd | |||
316236a7e5 | |||
c15faabd6d | |||
53eab74e60 | |||
82d908193c | |||
6620a6819a | |||
be6fec18ab | |||
9ebae03550 | |||
763a6efc9f | |||
6f04d23e6c | |||
155ddc556c | |||
a5a85e6032 | |||
6a3458a596 | |||
97be8f4667 |
13
.dockerignore
Normal file
13
.dockerignore
Normal file
@ -0,0 +1,13 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
*
|
||||
!Pipfile
|
||||
!Pipfile.lock
|
||||
!data/
|
||||
!ki/
|
||||
!LICENSES/
|
||||
!migrations/
|
||||
!app.py
|
||||
!run_prod.py
|
38
.drone.yml
38
.drone.yml
@ -15,15 +15,28 @@ trigger:
|
||||
|
||||
steps:
|
||||
- name: install-lint-test
|
||||
image: git.wtf-eg.de/kompetenzinventar/builder:1.0.2
|
||||
image: python:3.9.21-alpine@sha256:f2f6a5627a879693b8c23e04df0b1a6aae3e09c165fa2a08f5c64b2b54c58d3c
|
||||
env:
|
||||
PYROOT: '/pyroot'
|
||||
PYTHONUSERBASE: '/pyroot'
|
||||
commands:
|
||||
- apk add --no-cache gcc g++ musl-dev python3-dev
|
||||
- pip3 install pipenv
|
||||
- pipenv verify
|
||||
- pipenv install --dev
|
||||
- pipenv run flake8
|
||||
- pipenv run reuse lint
|
||||
- pipenv run python -m unittest discover ki
|
||||
|
||||
image_pull_secrets:
|
||||
- dockerconfig
|
||||
- SQLALCHEMY_DATABASE_URI=sqlite:// pipenv run python -m unittest discover ki
|
||||
- name: docker-dry-run
|
||||
image: plugins/docker:20.18.6@sha256:59c993e3c4e6c097a0e2d274419aac0d7d8e929773f0ba1af44078e54389834f
|
||||
settings:
|
||||
registry: git.wtf-eg.de
|
||||
repo: git.wtf-eg.de/kompetenzinventar/backend
|
||||
target: ki-backend
|
||||
dry_run: true
|
||||
when:
|
||||
event:
|
||||
- pull_request
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
@ -41,7 +54,7 @@ depends_on:
|
||||
|
||||
steps:
|
||||
- name: docker-publish
|
||||
image: plugins/docker
|
||||
image: plugins/docker:20.18.6@sha256:59c993e3c4e6c097a0e2d274419aac0d7d8e929773f0ba1af44078e54389834f
|
||||
settings:
|
||||
registry: git.wtf-eg.de
|
||||
repo: git.wtf-eg.de/kompetenzinventar/backend
|
||||
@ -68,7 +81,7 @@ depends_on:
|
||||
|
||||
steps:
|
||||
- name: deploy-dev
|
||||
image: appleboy/drone-ssh
|
||||
image: appleboy/drone-ssh:1.7.5@sha256:995677e073454912f26d4c0fdd2f9df2e1f5a30d6603d3f2ece667311b6babb3
|
||||
settings:
|
||||
host:
|
||||
- dev01.wtf-eg.net
|
||||
@ -91,14 +104,19 @@ trigger:
|
||||
|
||||
steps:
|
||||
- name: install-lint-test
|
||||
image: git.wtf-eg.de/kompetenzinventar/builder:1.0.2
|
||||
image: python:3.9.21-alpine@sha256:f2f6a5627a879693b8c23e04df0b1a6aae3e09c165fa2a08f5c64b2b54c58d3c
|
||||
env:
|
||||
PYROOT: '/pyroot'
|
||||
PYTHONUSERBASE: '/pyroot'
|
||||
commands:
|
||||
- apk add --no-cache gcc g++ musl-dev python3-dev
|
||||
- pip3 install pipenv
|
||||
- pipenv install --dev
|
||||
- pipenv run flake8
|
||||
- pipenv run reuse lint
|
||||
- pipenv run python -m unittest discover ki
|
||||
- SQLALCHEMY_DATABASE_URI=sqlite:// pipenv run python -m unittest discover ki
|
||||
- name: docker-publish
|
||||
image: plugins/docker
|
||||
image: plugins/docker:20.18.6@sha256:59c993e3c4e6c097a0e2d274419aac0d7d8e929773f0ba1af44078e54389834f
|
||||
settings:
|
||||
registry: git.wtf-eg.de
|
||||
repo: git.wtf-eg.de/kompetenzinventar/backend
|
||||
|
1
.python-version
Normal file
1
.python-version
Normal file
@ -0,0 +1 @@
|
||||
3.9.21
|
12
.reuse/dep5
12
.reuse/dep5
@ -1,12 +0,0 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: Kompetenzinventar
|
||||
Upstream-Contact: Michael Weimann <mail@michael-weimann.eu>
|
||||
Source: https://git.wtf-eg.de/kompetenzinventar/ki-backend
|
||||
|
||||
Files: data/imgs/flags/*
|
||||
Copyright: 2013 Panayiotis Lipiridis <https://flagicons.lipis.dev/>
|
||||
License: MIT
|
||||
|
||||
Files: Pipfile.lock migrations/*
|
||||
Copyright: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
License: AGPL-3.0-or-later
|
5
.yapfignore
Normal file
5
.yapfignore
Normal file
@ -0,0 +1,5 @@
|
||||
# SPDX-FileCopyrightText: WTF Kooperative eG <https://wtf-eg.de/>
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
migrations/*.py
|
17
Dockerfile
17
Dockerfile
@ -2,7 +2,17 @@
|
||||
#
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
||||
FROM git.wtf-eg.de/kompetenzinventar/builder:1.0.2 as builder
|
||||
FROM python:3.9.21-alpine@sha256:f2f6a5627a879693b8c23e04df0b1a6aae3e09c165fa2a08f5c64b2b54c58d3c AS builder
|
||||
|
||||
ENV PYROOT=/pyroot
|
||||
ENV PYTHONUSERBASE=$PYROOT
|
||||
|
||||
RUN apk add --no-cache \
|
||||
gcc \
|
||||
g++ \
|
||||
musl-dev \
|
||||
python3-dev && \
|
||||
pip3 install pipenv
|
||||
|
||||
COPY Pipfile* ./
|
||||
|
||||
@ -10,7 +20,10 @@ RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy --ignore-
|
||||
RUN pip3 uninstall --yes pipenv
|
||||
|
||||
|
||||
FROM git.wtf-eg.de/kompetenzinventar/base:1.0.2 as ki-backend
|
||||
FROM python:3.9.21-alpine@sha256:f2f6a5627a879693b8c23e04df0b1a6aae3e09c165fa2a08f5c64b2b54c58d3c AS ki-backend
|
||||
|
||||
ENV PYROOT=/pyroot
|
||||
ENV PYTHONUSERBASE=$PYROOT
|
||||
|
||||
# Install six explicitly. Otherwise Python complains about it missing.
|
||||
RUN pip3 install six
|
||||
|
31
Pipfile
31
Pipfile
@ -8,25 +8,26 @@ verify_ssl = true
|
||||
name = "pypi"
|
||||
|
||||
[packages]
|
||||
flask = "~=2.0.1"
|
||||
python-dotenv = "~=0.17.1"
|
||||
flask-migrate = "~=3.0.1"
|
||||
flask-sqlalchemy = "~=2.5.1"
|
||||
sqlalchemy = "~=1.4.18"
|
||||
waitress = "~=2.0.0"
|
||||
pyyaml = "~=6.0.1"
|
||||
flask-cors = "~=3.0.10"
|
||||
ldap3 = "~=2.9"
|
||||
pymysql = "~=1.0.2"
|
||||
flask = "==2.3.3"
|
||||
python-dotenv = "==1.0.1"
|
||||
flask-migrate = "==4.0.7"
|
||||
flask-sqlalchemy = "==3.1.1"
|
||||
sqlalchemy = "==2.0.36"
|
||||
waitress = "==2.1.2"
|
||||
pyyaml = "==6.0.2"
|
||||
flask-cors = "==5.0.0"
|
||||
ldap3 = "==2.9.1"
|
||||
pymysql = "==1.1.1"
|
||||
werkzeug = "==2.3.8"
|
||||
|
||||
[dev-packages]
|
||||
flake8 = "~=3.9.2"
|
||||
yapf = "~=0.31.0"
|
||||
pre-commit = "~=2.13.0"
|
||||
reuse = "~=0.13.0"
|
||||
flake8 = "==7.1.1"
|
||||
yapf = "==0.40.2"
|
||||
pre-commit = "==2.21.0"
|
||||
reuse = "==4.0.3"
|
||||
|
||||
[requires]
|
||||
python_version = "3.8"
|
||||
python_version = "3.9"
|
||||
|
||||
[scripts]
|
||||
clean = "rm data/ki.sqlite"
|
||||
|
1039
Pipfile.lock
generated
1039
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ Folgende Kanäle gibt es für die Kommunikation über das Kompetenzinventar:
|
||||
|
||||
### Abhängigkeiten
|
||||
|
||||
- Python 3.8
|
||||
- Python 3.9
|
||||
- [Pipenv](https://github.com/pypa/pipenv)
|
||||
|
||||
|
||||
|
24
REUSE.toml
Normal file
24
REUSE.toml
Normal file
@ -0,0 +1,24 @@
|
||||
# SPDX-FileCopyrightText: NONE
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
version = 1
|
||||
SPDX-PackageName = "Kompetenzinventar Backend"
|
||||
SPDX-PackageDownloadLocation = "https://git.wtf-eg.de/kompetenzinventar/ki-backend"
|
||||
|
||||
[[annotations]]
|
||||
path = "data/imgs/flags/**"
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "2013 Panayiotis Lipiridis <https://flagicons.lipis.dev/>"
|
||||
SPDX-License-Identifier = "MIT"
|
||||
|
||||
[[annotations]]
|
||||
path = ["Pipfile.lock", "migrations/**"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "WTF Kooperative eG <https://wtf-eg.de/>"
|
||||
SPDX-License-Identifier = "AGPL-3.0-or-later"
|
||||
|
||||
[[annotations]]
|
||||
path = ["renovate.json", ".python-version"]
|
||||
precedence = "aggregate"
|
||||
SPDX-FileCopyrightText = "WTF Kooperative eG <https://wtf-eg.de/>"
|
||||
SPDX-License-Identifier = "AGPL-3.0-or-later"
|
2
app.py
2
app.py
@ -38,7 +38,7 @@ app.config["KI_LDAP_AUTH_PASSWORD"] = os.getenv("KI_LDAP_AUTH_PASSWORD")
|
||||
app.config["KI_LDAP_BASE_DN"] = os.getenv("KI_LDAP_BASE_DN")
|
||||
|
||||
CORS(app)
|
||||
db = SQLAlchemy(app)
|
||||
db = SQLAlchemy(app, session_options={"future": True})
|
||||
migrate = Migrate(app, db, compare_type=True)
|
||||
|
||||
app.logger.info("Hello from KI")
|
||||
|
@ -19,7 +19,7 @@ def seed_contacttypes():
|
||||
|
||||
for contacttype in csv_reader:
|
||||
id = int(contacttype["id"])
|
||||
db_contacttype = ContactType.query.get(id)
|
||||
db_contacttype = db.session.get(ContactType, id)
|
||||
|
||||
if db_contacttype is None:
|
||||
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
||||
@ -88,71 +88,73 @@ def seed_user(auth_id,
|
||||
|
||||
|
||||
def seed(dev: bool):
|
||||
seed_contacttypes()
|
||||
with app.app_context():
|
||||
seed_contacttypes()
|
||||
|
||||
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
|
||||
skill_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/skills.csv"
|
||||
|
||||
app.logger.info("importing skills")
|
||||
app.logger.info("importing skills")
|
||||
|
||||
with open(skill_seed_file_path) as skills_file:
|
||||
skills_csv_reader = csv.DictReader(skills_file)
|
||||
with open(skill_seed_file_path) as skills_file:
|
||||
skills_csv_reader = csv.DictReader(skills_file)
|
||||
|
||||
for skill in skills_csv_reader:
|
||||
id = int(skill["id"])
|
||||
db_skill = Skill.query.get(id)
|
||||
for skill in skills_csv_reader:
|
||||
id = int(skill["id"])
|
||||
db_skill = db.session.get(Skill, id)
|
||||
|
||||
if db_skill is None:
|
||||
db.session.add(Skill(id=int(skill["id"]), name=skill["name"]))
|
||||
if db_skill is None:
|
||||
db.session.add(Skill(id=int(skill["id"]), name=skill["name"]))
|
||||
|
||||
app.logger.info("importing languages")
|
||||
app.logger.info("importing languages")
|
||||
|
||||
iso_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/iso_639_1.csv"
|
||||
iso_seed_file_path = app.config["KI_DATA_DIR"] + "/seed_data/iso_639_1.csv"
|
||||
|
||||
with open(iso_seed_file_path) as iso_file:
|
||||
iso_csv_reader = csv.DictReader(iso_file)
|
||||
with open(iso_seed_file_path) as iso_file:
|
||||
iso_csv_reader = csv.DictReader(iso_file)
|
||||
|
||||
for iso in iso_csv_reader:
|
||||
id = iso["639-1"]
|
||||
db_language = Language.query.get(id)
|
||||
for iso in iso_csv_reader:
|
||||
id = iso["639-1"]
|
||||
db_language = db.session.get(Language, id)
|
||||
|
||||
if db_language is None:
|
||||
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
||||
if db_language is None:
|
||||
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
||||
|
||||
if dev:
|
||||
seed_user("klaus", visible=False)
|
||||
if dev:
|
||||
seed_user("klaus", visible=False)
|
||||
|
||||
for i in range(1, 20):
|
||||
seed_user(f"babsi{i}")
|
||||
for i in range(1, 20):
|
||||
seed_user(f"babsi{i}")
|
||||
|
||||
seed_user("peter",
|
||||
nickname="peternichtlustig",
|
||||
visible=False,
|
||||
pronouns="Herr Dr. Dr.",
|
||||
volunteerwork="Gartenverein",
|
||||
availability_status=True,
|
||||
availability_hours_per_week=42,
|
||||
availability_text="Immer",
|
||||
freetext="Ich mag Kaffee",
|
||||
skills=[(3, 3), (1, 5)],
|
||||
searchtopics=[3, 1],
|
||||
languages=[("de", 5), ("fr", 3)],
|
||||
address=("Peter Nichtlustig", "Waldweg", "23i", "Hinterhaus", "13337", "Bielefeld", "Deutschland"),
|
||||
contacts=[(4, "@peter:wtf-eg.de"), (1, "peter@wtf-eg.de")])
|
||||
seed_user("peter",
|
||||
nickname="peternichtlustig",
|
||||
visible=False,
|
||||
pronouns="Herr Dr. Dr.",
|
||||
volunteerwork="Gartenverein",
|
||||
availability_status=True,
|
||||
availability_hours_per_week=42,
|
||||
availability_text="Immer",
|
||||
freetext="Ich mag Kaffee",
|
||||
skills=[(3, 3), (1, 5)],
|
||||
searchtopics=[3, 1],
|
||||
languages=[("de", 5), ("fr", 3)],
|
||||
address=("Peter Nichtlustig", "Waldweg", "23i", "Hinterhaus", "13337", "Bielefeld",
|
||||
"Deutschland"),
|
||||
contacts=[(4, "@peter:wtf-eg.de"), (1, "peter@wtf-eg.de")])
|
||||
|
||||
seed_user("dirtydieter",
|
||||
volunteerwork="Müll sammeln",
|
||||
availability_status=True,
|
||||
availability_hours_per_week=24,
|
||||
availability_text="Nur Nachts!",
|
||||
freetext="1001010010111!!!",
|
||||
skills=[(1, 5)],
|
||||
address=("Friedrich Witzig", "", "", "", "", "", ""))
|
||||
seed_user("dirtydieter",
|
||||
volunteerwork="Müll sammeln",
|
||||
availability_status=True,
|
||||
availability_hours_per_week=24,
|
||||
availability_text="Nur Nachts!",
|
||||
freetext="1001010010111!!!",
|
||||
skills=[(1, 5)],
|
||||
address=("Friedrich Witzig", "", "", "", "", "", ""))
|
||||
|
||||
all_skills = [(skill.id, 3) for skill in Skill.query.all()]
|
||||
seed_user("jutta", languages=[("fr", 5)], skills=all_skills)
|
||||
all_skills = [(skill.id, 3) for skill in Skill.query.all()]
|
||||
seed_user("jutta", languages=[("fr", 5)], skills=all_skills)
|
||||
|
||||
seed_user("giesela", skills=[(9, 3), (10, 5)])
|
||||
seed_user("bertha", visible=False, skills=[(11, 3), (10, 5)])
|
||||
seed_user("monique", languages=[("fr", 4)])
|
||||
seed_user("giesela", skills=[(9, 3), (10, 5)])
|
||||
seed_user("bertha", visible=False, skills=[(11, 3), (10, 5)])
|
||||
seed_user("monique", languages=[("fr", 4)])
|
||||
|
||||
db.session.commit()
|
||||
db.session.commit()
|
||||
|
@ -33,7 +33,7 @@ def update_languages(profile, languages_data):
|
||||
if "id" not in language_data["language"]:
|
||||
continue
|
||||
|
||||
language = Language.query.get(language_data["language"]["id"])
|
||||
language = db.session.get(Language, language_data["language"]["id"])
|
||||
profile_language = ProfileLanguage.query.filter(ProfileLanguage.profile == profile,
|
||||
ProfileLanguage.language == language).first()
|
||||
|
||||
@ -110,7 +110,7 @@ def update_contacts(profile, contacts_data):
|
||||
if "id" in contact_data:
|
||||
contact_id = int(contact_data["id"])
|
||||
contact_ids_to_be_deleted.remove(contact_id)
|
||||
contact = Contact.query.get(contact_id)
|
||||
contact = db.session.get(Contact, contact_id)
|
||||
else:
|
||||
contact = Contact(profile=profile, contacttype=contacttype)
|
||||
db.session.add(contact)
|
||||
@ -122,7 +122,7 @@ def update_contacts(profile, contacts_data):
|
||||
|
||||
|
||||
def update_profile(user_id: int):
|
||||
user = User.query.get(user_id)
|
||||
user = db.session.get(User, user_id)
|
||||
|
||||
if user is None:
|
||||
return make_response({}, 404)
|
||||
|
@ -10,13 +10,14 @@ from ki.auth import auth
|
||||
from ki.handlers import find_profiles as find_profiles_handler
|
||||
from ki.handlers import update_profile as update_profile_handler
|
||||
from ki.models import ContactType, Language, Skill, Token, User
|
||||
from app import app
|
||||
from app import app, db
|
||||
|
||||
content_type_svg = "image/svg+xml"
|
||||
content_type_png = "image/png"
|
||||
|
||||
|
||||
def token_auth(func):
|
||||
|
||||
@wraps(func)
|
||||
def _token_auth(*args, **kwargs):
|
||||
auth_header = request.headers.get("Authorization")
|
||||
@ -65,7 +66,7 @@ def handle_completion_request(model, key):
|
||||
|
||||
|
||||
def handle_icon_request(model, id, path):
|
||||
object = model.query.get(id)
|
||||
object = db.session.get(model, id)
|
||||
|
||||
if object is None:
|
||||
return make_response({}, 404)
|
||||
|
@ -26,13 +26,14 @@ class ApiTest(unittest.TestCase):
|
||||
config = migrate.get_config()
|
||||
command.upgrade(config, "head")
|
||||
|
||||
seed(True)
|
||||
max_skill = Skill.query.order_by(Skill.id.desc()).first()
|
||||
self.max_skill_id = max_skill.id
|
||||
seed(True)
|
||||
max_skill = Skill.query.order_by(Skill.id.desc()).first()
|
||||
self.max_skill_id = max_skill.id
|
||||
|
||||
def tearDown(self):
|
||||
db.drop_all()
|
||||
db.engine.dispose()
|
||||
with app.app_context():
|
||||
db.drop_all()
|
||||
db.engine.dispose()
|
||||
|
||||
def login(self, username, password):
|
||||
login_data = {"username": username, "password": password}
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestContactTypesEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/contacttypes")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestFindProfilesEndpoint(ApiTest):
|
||||
|
||||
def test_find_profiles_options(self):
|
||||
response = self.client.options("/users/profiles")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestLanguagesEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/languages")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@ -32,6 +33,7 @@ class TestLanguagesEndpoint(ApiTest):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn("Content-Type", response.headers)
|
||||
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
|
||||
response.close()
|
||||
|
||||
|
||||
if __name__ == "main":
|
||||
|
@ -10,6 +10,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestLoginEndpoint(ApiTest):
|
||||
|
||||
def test_login(self):
|
||||
response1_data = self.login("peter", "geheim")
|
||||
response2_data = self.login("peter", "geheim")
|
||||
|
@ -20,11 +20,12 @@ class TestProfileEndpoint(ApiTest):
|
||||
self.assertEqual(login_response.status_code, 200)
|
||||
self.assertIn("token", login_response.json)
|
||||
|
||||
babsi = User.query.filter(User.auth_id == "babsi1").first()
|
||||
response = self.client.post(f"/users/{babsi.id}/profile",
|
||||
data=json.dumps({}),
|
||||
content_type="application/json",
|
||||
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||
with app.app_context():
|
||||
babsi = User.query.filter(User.auth_id == "babsi1").first()
|
||||
response = self.client.post(f"/users/{babsi.id}/profile",
|
||||
data=json.dumps({}),
|
||||
content_type="application/json",
|
||||
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||
|
||||
self.assertEqual(response.status_code, 403)
|
||||
|
||||
@ -103,11 +104,12 @@ class TestProfileEndpoint(ApiTest):
|
||||
"level": 2
|
||||
}]
|
||||
}
|
||||
peter = User.query.filter(User.auth_id == "peter").first()
|
||||
response = self.client.post(f"/users/{peter.id}/profile",
|
||||
data=json.dumps(data),
|
||||
content_type="application/json",
|
||||
headers={"Authorization": "Bearer " + token})
|
||||
with app.app_context():
|
||||
peter = User.query.filter(User.auth_id == "peter").first()
|
||||
response = self.client.post(f"/users/{peter.id}/profile",
|
||||
data=json.dumps(data),
|
||||
content_type="application/json",
|
||||
headers={"Authorization": "Bearer " + token})
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
with app.app_context():
|
||||
@ -185,8 +187,9 @@ class TestProfileEndpoint(ApiTest):
|
||||
def test_get_visible_proifle(self):
|
||||
token = self.login("peter", "geheim")["token"]
|
||||
|
||||
babsi = User.query.filter(User.auth_id == "babsi1").first()
|
||||
response = self.client.get(f"/users/{babsi.id}/profile", headers={"Authorization": f"Bearer {token}"})
|
||||
with app.app_context():
|
||||
babsi = User.query.filter(User.auth_id == "babsi1").first()
|
||||
response = self.client.get(f"/users/{babsi.id}/profile", headers={"Authorization": f"Bearer {token}"})
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
@ -197,10 +200,11 @@ class TestProfileEndpoint(ApiTest):
|
||||
self.assertEqual(login_response.status_code, 200)
|
||||
self.assertIn("token", login_response.json)
|
||||
|
||||
peter = User.query.filter(User.auth_id == "peter").first()
|
||||
response = self.client.get(f"/users/{peter.id}/profile",
|
||||
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||
profile_id = peter.profile.id
|
||||
with app.app_context():
|
||||
peter = User.query.filter(User.auth_id == "peter").first()
|
||||
response = self.client.get(f"/users/{peter.id}/profile",
|
||||
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||
profile_id = peter.profile.id
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertDictEqual(
|
||||
response.json, {
|
||||
|
@ -8,6 +8,7 @@ from ki.test.ApiTest import ApiTest
|
||||
|
||||
|
||||
class TestSkillsEndpoint(ApiTest):
|
||||
|
||||
def test_skills_options(self):
|
||||
response = self.client.options("/skills")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
@ -40,12 +41,14 @@ class TestSkillsEndpoint(ApiTest):
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn("Content-Type", response.headers)
|
||||
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
|
||||
response.close()
|
||||
|
||||
def test_get_fallback_skill_icon(self):
|
||||
response = self.client.get("/skills/2/icon")
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertIn("Content-Type", response.headers)
|
||||
self.assertEqual(response.headers["Content-Type"], "image/svg+xml; charset=utf-8")
|
||||
response.close()
|
||||
|
||||
|
||||
if __name__ == "main":
|
||||
|
@ -19,7 +19,7 @@ logger = logging.getLogger('alembic.env')
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
config.set_main_option(
|
||||
'sqlalchemy.url',
|
||||
str(current_app.extensions['migrate'].db.get_engine().url).replace(
|
||||
str(current_app.extensions['migrate'].db.engine.url).replace(
|
||||
'%', '%%'))
|
||||
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||
|
||||
@ -68,7 +68,7 @@ def run_migrations_online():
|
||||
directives[:] = []
|
||||
logger.info('No changes in schema detected.')
|
||||
|
||||
connectable = current_app.extensions['migrate'].db.get_engine()
|
||||
connectable = current_app.extensions['migrate'].db.engine
|
||||
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
|
18
renovate.json
Normal file
18
renovate.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
||||
"extends": [
|
||||
"config:best-practices",
|
||||
":disableDependencyDashboard",
|
||||
":maintainLockFilesMonthly",
|
||||
":pinVersions",
|
||||
":separateMultipleMajorReleases"
|
||||
],
|
||||
"packageRules": [
|
||||
{
|
||||
"matchDepNames": ["python"],
|
||||
"groupName": "Python",
|
||||
"separateMinorPatch": true,
|
||||
"separateMultipleMinor": true
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user