forked from kompetenzinventar/ki-backend
Compare commits
17 Commits
test/docke
...
main
Author | SHA1 | Date | |
---|---|---|---|
9a7a9379e2 | |||
5b707ad294 | |||
c05f040313 | |||
68bf505cd0 | |||
2ac03d0c26 | |||
6b46ea5516 | |||
4798263c27 | |||
|
274f984994 | ||
|
37f57eadea | ||
d7f4acf251 | |||
c65ef4a95c | |||
f3840f18b7 | |||
da46d01765 | |||
0f9f807256 | |||
66294cd52f | |||
|
d4a5c8f5eb | ||
|
6e77647eb9 |
96
.drone.yml
96
.drone.yml
@ -4,10 +4,17 @@
|
|||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: docker
|
type: docker
|
||||||
name: default
|
name: qa
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
- pull_request
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: qa
|
- name: install-lint-test
|
||||||
image: registry.wtf-eg.net/ki-backend-builder:1.0.0
|
image: registry.wtf-eg.net/ki-backend-builder:1.0.0
|
||||||
commands:
|
commands:
|
||||||
- pipenv install --dev
|
- pipenv install --dev
|
||||||
@ -15,24 +22,25 @@ steps:
|
|||||||
- pipenv run reuse lint
|
- pipenv run reuse lint
|
||||||
- pipenv run python -m unittest discover ki
|
- pipenv run python -m unittest discover ki
|
||||||
|
|
||||||
- name: docker-publish
|
image_pull_secrets:
|
||||||
image: plugins/docker
|
- dockerconfig
|
||||||
settings:
|
|
||||||
registry: registry.wtf-eg.net
|
---
|
||||||
repo: registry.wtf-eg.net/ki-backend
|
kind: pipeline
|
||||||
target: ki-backend
|
type: docker
|
||||||
auto_tag: true
|
name: build
|
||||||
username:
|
|
||||||
from_secret: "docker_username"
|
trigger:
|
||||||
password:
|
|
||||||
from_secret: "docker_password"
|
|
||||||
when:
|
|
||||||
event:
|
event:
|
||||||
- push
|
- push
|
||||||
branch:
|
branch:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
- name: docker-publish-tag
|
depends_on:
|
||||||
|
- qa
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: docker-publish
|
||||||
image: plugins/docker
|
image: plugins/docker
|
||||||
settings:
|
settings:
|
||||||
registry: registry.wtf-eg.net
|
registry: registry.wtf-eg.net
|
||||||
@ -43,9 +51,63 @@ steps:
|
|||||||
from_secret: "docker_username"
|
from_secret: "docker_username"
|
||||||
password:
|
password:
|
||||||
from_secret: "docker_password"
|
from_secret: "docker_password"
|
||||||
when:
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: deploy
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
event:
|
||||||
|
- push
|
||||||
|
branch:
|
||||||
|
- main
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: deploy-dev
|
||||||
|
image: appleboy/drone-ssh
|
||||||
|
settings:
|
||||||
|
host:
|
||||||
|
- dev01.wtf-eg.net
|
||||||
|
username: drone_deployment
|
||||||
|
key:
|
||||||
|
from_secret: "dev01_deployment_key"
|
||||||
|
command_timeout: 2m
|
||||||
|
script:
|
||||||
|
- echo "Executing forced command..."
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: tag-release
|
||||||
|
|
||||||
|
trigger:
|
||||||
event:
|
event:
|
||||||
- tag
|
- tag
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: install-lint-test
|
||||||
|
image: registry.wtf-eg.net/ki-backend-builder:1.0.0
|
||||||
|
commands:
|
||||||
|
- pipenv install --dev
|
||||||
|
- pipenv run flake8
|
||||||
|
- pipenv run reuse lint
|
||||||
|
- pipenv run python -m unittest discover ki
|
||||||
|
- name: docker-publish
|
||||||
|
image: plugins/docker
|
||||||
|
settings:
|
||||||
|
registry: registry.wtf-eg.net
|
||||||
|
repo: registry.wtf-eg.net/ki-backend
|
||||||
|
target: ki-backend
|
||||||
|
auto_tag: true
|
||||||
|
username:
|
||||||
|
from_secret: "docker_username"
|
||||||
|
password:
|
||||||
|
from_secret: "docker_password"
|
||||||
|
|
||||||
image_pull_secrets:
|
image_pull_secrets:
|
||||||
- dockerconfig
|
- dockerconfig
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#
|
#
|
||||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||||
|
|
||||||
FROM registry.wtf-eg.net/ki-backend-builder:1.0.0 as builder
|
FROM registry.wtf-eg.net/ki-backend-builder:1.0.1 as builder
|
||||||
|
|
||||||
COPY Pipfile* ./
|
COPY Pipfile* ./
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ RUN PIP_USER=1 PIP_IGNORE_INSTALLED=1 pipenv install --system --deploy --ignore-
|
|||||||
RUN pip3 uninstall --yes pipenv
|
RUN pip3 uninstall --yes pipenv
|
||||||
|
|
||||||
|
|
||||||
FROM registry.wtf-eg.net/ki-backend-base:1.0.0 as ki-backend
|
FROM registry.wtf-eg.net/ki-backend-base:1.0.1 as ki-backend
|
||||||
|
|
||||||
# Install six explicitly. Otherwise Python complains about it missing.
|
# Install six explicitly. Otherwise Python complains about it missing.
|
||||||
RUN pip3 install six
|
RUN pip3 install six
|
||||||
@ -22,4 +22,9 @@ WORKDIR /app
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
|
LABEL org.opencontainers.image.source=https://git.wtf-eg.de/kompetenzinventar/ki-backend.git
|
||||||
|
LABEL org.opencontainers.image.url=https://git.wtf-eg.de/kompetenzinventar/ki-backend
|
||||||
|
LABEL org.opencontainers.image.documentation=https://git.wtf-eg.de/kompetenzinventar/ki-backend#docker
|
||||||
|
LABEL org.opencontainers.image.vendor="WTF Kooperative eG"
|
||||||
|
|
||||||
CMD ["python3", "run_prod.py"]
|
CMD ["python3", "run_prod.py"]
|
||||||
|
@ -25,22 +25,30 @@ def seed_contacttypes():
|
|||||||
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
db.session.add(ContactType(id=int(contacttype["id"]), name=contacttype["name"]))
|
||||||
|
|
||||||
|
|
||||||
def seed_user(nickname,
|
def seed_user(auth_id,
|
||||||
visible=False,
|
nickname=None,
|
||||||
skills=[],
|
pronouns="",
|
||||||
languages=[],
|
visible=True,
|
||||||
volunteerwork="",
|
volunteerwork="",
|
||||||
availability_status=False,
|
availability_status=False,
|
||||||
freetext="",
|
freetext="",
|
||||||
availability_text="",
|
availability_text="",
|
||||||
availability_hours_per_week=42):
|
availability_hours_per_week=42,
|
||||||
|
skills=[],
|
||||||
|
searchtopics=[],
|
||||||
|
languages=[],
|
||||||
|
address=None,
|
||||||
|
contacts=[]):
|
||||||
|
if not nickname:
|
||||||
|
nickname = auth_id
|
||||||
|
|
||||||
app.logger.info(f"seeding {nickname} \\o/")
|
app.logger.info(f"seeding {nickname} \\o/")
|
||||||
|
|
||||||
user = User(auth_id=nickname)
|
user = User(auth_id=auth_id)
|
||||||
db.session.add(user)
|
db.session.add(user)
|
||||||
|
|
||||||
profile = Profile(nickname=nickname,
|
profile = Profile(nickname=nickname,
|
||||||
pronouns="",
|
pronouns=pronouns,
|
||||||
volunteerwork=volunteerwork,
|
volunteerwork=volunteerwork,
|
||||||
availability_status=availability_status,
|
availability_status=availability_status,
|
||||||
availability_text=availability_text,
|
availability_text=availability_text,
|
||||||
@ -53,10 +61,29 @@ def seed_user(nickname,
|
|||||||
skill = ProfileSkill(profile=profile, skill_id=skill_data[0], level=skill_data[1])
|
skill = ProfileSkill(profile=profile, skill_id=skill_data[0], level=skill_data[1])
|
||||||
db.session.add(skill)
|
db.session.add(skill)
|
||||||
|
|
||||||
|
for skill_id in searchtopics:
|
||||||
|
searchtopic = ProfileSearchtopic(profile=profile, skill_id=skill_id)
|
||||||
|
db.session.add(searchtopic)
|
||||||
|
|
||||||
for language_data in languages:
|
for language_data in languages:
|
||||||
language = ProfileLanguage(profile=profile, language_id=language_data[0], level=language_data[1])
|
language = ProfileLanguage(profile=profile, language_id=language_data[0], level=language_data[1])
|
||||||
db.session.add(language)
|
db.session.add(language)
|
||||||
|
|
||||||
|
if address:
|
||||||
|
_address = Address(name=address[0],
|
||||||
|
street=address[1],
|
||||||
|
house_number=address[2],
|
||||||
|
additional=address[3],
|
||||||
|
postcode=address[4],
|
||||||
|
city=address[5],
|
||||||
|
country=address[6],
|
||||||
|
profile=profile)
|
||||||
|
db.session.add(_address)
|
||||||
|
|
||||||
|
for contact_data in contacts:
|
||||||
|
contact = Contact(profile=profile, contacttype_id=contact_data[0], content=contact_data[1])
|
||||||
|
db.session.add(contact)
|
||||||
|
|
||||||
db.session.add(profile)
|
db.session.add(profile)
|
||||||
|
|
||||||
|
|
||||||
@ -92,77 +119,40 @@ def seed(dev: bool):
|
|||||||
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
db.session.add(Language(id=iso["639-1"], name=iso["Sprache"]))
|
||||||
|
|
||||||
if dev:
|
if dev:
|
||||||
app.logger.info("seeding peter :)")
|
seed_user("klaus", visible=False)
|
||||||
|
|
||||||
peter = User(auth_id="peter")
|
for i in range(1, 20):
|
||||||
db.session.add(peter)
|
seed_user(f"babsi{i}")
|
||||||
|
|
||||||
peters_profile = Profile(nickname="peternichtlustig",
|
seed_user("peter",
|
||||||
|
nickname="peternichtlustig",
|
||||||
|
visible=False,
|
||||||
pronouns="Herr Dr. Dr.",
|
pronouns="Herr Dr. Dr.",
|
||||||
volunteerwork="Gartenverein",
|
volunteerwork="Gartenverein",
|
||||||
availability_status=True,
|
availability_status=True,
|
||||||
availability_hours_per_week=42,
|
availability_hours_per_week=42,
|
||||||
availability_text="Immer",
|
availability_text="Immer",
|
||||||
freetext="Ich mag Kaffee",
|
freetext="Ich mag Kaffee",
|
||||||
user=peter)
|
skills=[(3, 3), (1, 5)],
|
||||||
db.session.add(peters_profile)
|
searchtopics=[3, 1],
|
||||||
|
languages=[("de", 5), ("fr", 3)],
|
||||||
matrix_contact = Contact(profile=peters_profile, contacttype_id=4, content="@peter:wtf-eg.de")
|
address=("Peter Nichtlustig", "Waldweg", "23i", "Hinterhaus", "13337", "Bielefeld", "Deutschland"),
|
||||||
db.session.add(matrix_contact)
|
contacts=[(4, "@peter:wtf-eg.de"), (1, "peter@wtf-eg.de")])
|
||||||
|
|
||||||
email_contact = Contact(profile=peters_profile, contacttype_id=1, content="peter@wtf-eg.de")
|
|
||||||
db.session.add(email_contact)
|
|
||||||
|
|
||||||
peters_address = Address(name="Peter Nichtlustig",
|
|
||||||
street="Waldweg",
|
|
||||||
house_number="23i",
|
|
||||||
additional="Hinterhaus",
|
|
||||||
postcode="13337",
|
|
||||||
city="Bielefeld",
|
|
||||||
country="Deutschland",
|
|
||||||
profile=peters_profile)
|
|
||||||
db.session.add(peters_address)
|
|
||||||
|
|
||||||
peters_python_skill = ProfileSkill(profile=peters_profile, skill_id=3, level=3)
|
|
||||||
db.session.add(peters_python_skill)
|
|
||||||
|
|
||||||
peters_php_skill = ProfileSkill(profile=peters_profile, skill_id=1, level=5)
|
|
||||||
db.session.add(peters_php_skill)
|
|
||||||
|
|
||||||
peters_python_searchtopic = ProfileSearchtopic(profile=peters_profile, skill_id=3)
|
|
||||||
db.session.add(peters_python_searchtopic)
|
|
||||||
|
|
||||||
peters_php_searchtopic = ProfileSearchtopic(profile=peters_profile, skill_id=1)
|
|
||||||
db.session.add(peters_php_searchtopic)
|
|
||||||
|
|
||||||
peter_de = ProfileLanguage(profile=peters_profile, language_id="de", level=5)
|
|
||||||
db.session.add(peter_de)
|
|
||||||
|
|
||||||
peter_fr = ProfileLanguage(profile=peters_profile, language_id="fr", level=3)
|
|
||||||
db.session.add(peter_fr)
|
|
||||||
|
|
||||||
seed_user("klaus")
|
|
||||||
for i in range(1, 20):
|
|
||||||
seed_user(f"babsi{i}", visible=True)
|
|
||||||
|
|
||||||
seed_user("dirtydieter",
|
seed_user("dirtydieter",
|
||||||
visible=True,
|
|
||||||
volunteerwork="Müll sammeln",
|
volunteerwork="Müll sammeln",
|
||||||
availability_status=True,
|
availability_status=True,
|
||||||
availability_hours_per_week=24,
|
availability_hours_per_week=24,
|
||||||
availability_text="Nur Nachts!",
|
availability_text="Nur Nachts!",
|
||||||
freetext="1001010010111!!!",
|
freetext="1001010010111!!!",
|
||||||
skills=[(Skill.skill_id_php, 5)])
|
skills=[(1, 5)],
|
||||||
|
address=("Friedrich Witzig", "", "", "", "", "", ""))
|
||||||
|
|
||||||
all_skills = Skill.query.all()
|
all_skills = [(skill.id, 3) for skill in Skill.query.all()]
|
||||||
all_profile_skills = []
|
seed_user("jutta", languages=[("fr", 5)], skills=all_skills)
|
||||||
for skill in all_skills:
|
|
||||||
all_profile_skills.append((skill.id, 3))
|
|
||||||
|
|
||||||
seed_user("jutta", visible=True, languages=[("fr", 5)], skills=all_profile_skills)
|
seed_user("giesela", skills=[(9, 3), (10, 5)])
|
||||||
seed_user("giesela", visible=True, skills=[(Skill.skill_id_mysql, 3), (Skill.skill_id_postgresql, 5)])
|
seed_user("bertha", visible=False, skills=[(11, 3), (10, 5)])
|
||||||
seed_user("bertha", visible=False, skills=[(Skill.skill_id_sqlite, 3), (Skill.skill_id_postgresql, 5)])
|
seed_user("monique", languages=[("fr", 4)])
|
||||||
|
|
||||||
seed_user("monique", visible=True, languages=[("fr", 4)])
|
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
from flask import make_response, request
|
from flask import make_response, request
|
||||||
|
|
||||||
from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language
|
from ki.models import Profile, ProfileSkill, Skill, ProfileLanguage, Language, Address
|
||||||
|
|
||||||
|
|
||||||
def find_profiles():
|
def find_profiles():
|
||||||
@ -25,13 +25,18 @@ def find_profiles():
|
|||||||
.order_by(Profile.nickname) \
|
.order_by(Profile.nickname) \
|
||||||
.filter(Profile.visible.is_(True)) \
|
.filter(Profile.visible.is_(True)) \
|
||||||
.join(Profile.skills, isouter=True).join(ProfileSkill.skill, isouter=True) \
|
.join(Profile.skills, isouter=True).join(ProfileSkill.skill, isouter=True) \
|
||||||
.join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True)
|
.join(Profile.languages, isouter=True).join(ProfileLanguage.language, isouter=True) \
|
||||||
|
.join(Address, isouter=True)
|
||||||
|
|
||||||
if "search" in request.args:
|
if "search" in request.args:
|
||||||
terms = request.args["search"].split(" ")
|
terms = request.args["search"].split(" ")
|
||||||
for term in terms:
|
for term in terms:
|
||||||
|
|
||||||
query = query.filter(
|
query = query.filter(
|
||||||
Profile.nickname.like(f"%{term}%") | Skill.name.like(f"%{term}%") | Language.name.like(f"%{term}%"))
|
Profile.nickname.like(f"%{term}%") | # noqa: W504
|
||||||
|
Skill.name.like(f"%{term}%") | # noqa: W504
|
||||||
|
Language.name.like(f"%{term}%") | # noqa: W504
|
||||||
|
Address.name.like(f"%{term}%"))
|
||||||
|
|
||||||
if "nickname" in request.args:
|
if "nickname" in request.args:
|
||||||
nickname = request.args.get("nickname")
|
nickname = request.args.get("nickname")
|
||||||
|
@ -151,11 +151,11 @@ def update_profile(user_id: int):
|
|||||||
profile.freetext = request.json.get("freetext", "")
|
profile.freetext = request.json.get("freetext", "")
|
||||||
profile.visible = request.json.get("visible", False)
|
profile.visible = request.json.get("visible", False)
|
||||||
|
|
||||||
update_address(profile, request.json.get("address", {}))
|
update_address(profile, request.json.get("address"))
|
||||||
update_contacts(profile, request.json.get("contacts", {}))
|
update_contacts(profile, request.json.get("contacts", []))
|
||||||
update_skills(profile, request.json.get("skills", {}))
|
update_skills(profile, request.json.get("skills", []))
|
||||||
update_searchtopics(profile, request.json.get("searchtopics"))
|
update_searchtopics(profile, request.json.get("searchtopics", []))
|
||||||
update_languages(profile, request.json.get("languages", {}))
|
update_languages(profile, request.json.get("languages", []))
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
@ -139,13 +139,6 @@ class Address(db.Model):
|
|||||||
|
|
||||||
|
|
||||||
class Skill(db.Model):
|
class Skill(db.Model):
|
||||||
skill_id_php = 1
|
|
||||||
skill_id_python = 3
|
|
||||||
skill_id_sqlalchemy = 7
|
|
||||||
skill_id_mysql = 9
|
|
||||||
skill_id_postgresql = 10
|
|
||||||
skill_id_sqlite = 11
|
|
||||||
|
|
||||||
__tablename__ = "skill"
|
__tablename__ = "skill"
|
||||||
|
|
||||||
id = Column(Integer, primary_key=True)
|
id = Column(Integer, primary_key=True)
|
||||||
|
@ -99,6 +99,14 @@ class TestFindProfilesEndpoint(ApiTest):
|
|||||||
self.assertDictContainsSubset({"nickname": "jutta"}, response.json["profiles"][0])
|
self.assertDictContainsSubset({"nickname": "jutta"}, response.json["profiles"][0])
|
||||||
self.assertDictContainsSubset({"nickname": "monique"}, response.json["profiles"][1])
|
self.assertDictContainsSubset({"nickname": "monique"}, response.json["profiles"][1])
|
||||||
|
|
||||||
|
def test_find_dieter_by_name(self):
|
||||||
|
token = self.login("peter", "geheim")["token"]
|
||||||
|
|
||||||
|
response = self.client.get("/users/profiles?search=friedrich", headers={"Authorization": "Bearer " + token})
|
||||||
|
self.assertEqual(response.status_code, 200)
|
||||||
|
self.assertDictContainsSubset({"total": 1}, response.json)
|
||||||
|
self.assertDictContainsSubset({"nickname": "dirtydieter"}, response.json["profiles"][0])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "main":
|
if __name__ == "main":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
@ -20,7 +20,8 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
self.assertEqual(login_response.status_code, 200)
|
self.assertEqual(login_response.status_code, 200)
|
||||||
self.assertIn("token", login_response.json)
|
self.assertIn("token", login_response.json)
|
||||||
|
|
||||||
response = self.client.post("/users/1/profile",
|
babsi = User.query.filter(User.auth_id == "babsi1").first()
|
||||||
|
response = self.client.post(f"/users/{babsi.id}/profile",
|
||||||
data=json.dumps({}),
|
data=json.dumps({}),
|
||||||
content_type="application/json",
|
content_type="application/json",
|
||||||
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||||
@ -102,14 +103,15 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"level": 2
|
"level": 2
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
response = self.client.post("/users/1/profile",
|
peter = User.query.filter(User.auth_id == "peter").first()
|
||||||
|
response = self.client.post(f"/users/{peter.id}/profile",
|
||||||
data=json.dumps(data),
|
data=json.dumps(data),
|
||||||
content_type="application/json",
|
content_type="application/json",
|
||||||
headers={"Authorization": "Bearer " + token})
|
headers={"Authorization": "Bearer " + token})
|
||||||
|
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
user = User.query.filter(User.id == 1).first()
|
user = User.query.filter(User.id == peter.id).first()
|
||||||
profile = user.profile
|
profile = user.profile
|
||||||
self.assertEqual("Hebbert", profile.nickname)
|
self.assertEqual("Hebbert", profile.nickname)
|
||||||
self.assertEqual("Monsieur", profile.pronouns)
|
self.assertEqual("Monsieur", profile.pronouns)
|
||||||
@ -183,7 +185,8 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
def test_get_visible_proifle(self):
|
def test_get_visible_proifle(self):
|
||||||
token = self.login("peter", "geheim")["token"]
|
token = self.login("peter", "geheim")["token"]
|
||||||
|
|
||||||
response = self.client.get("/users/3/profile", headers={"Authorization": f"Bearer {token}"})
|
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)
|
self.assertEqual(response.status_code, 200)
|
||||||
|
|
||||||
@ -194,14 +197,15 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
self.assertEqual(login_response.status_code, 200)
|
self.assertEqual(login_response.status_code, 200)
|
||||||
self.assertIn("token", login_response.json)
|
self.assertIn("token", login_response.json)
|
||||||
|
|
||||||
response = self.client.get("/users/1/profile",
|
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"]})
|
headers={"Authorization": "Bearer " + login_response.json["token"]})
|
||||||
|
profile_id = peter.profile.id
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, 200)
|
||||||
self.assertDictEqual(
|
self.assertDictEqual(
|
||||||
response.json, {
|
response.json, {
|
||||||
"profile": {
|
"profile": {
|
||||||
"user_id": 1,
|
"user_id": peter.id,
|
||||||
"nickname": "peternichtlustig",
|
"nickname": "peternichtlustig",
|
||||||
"pronouns": "Herr Dr. Dr.",
|
"pronouns": "Herr Dr. Dr.",
|
||||||
"availability_status": True,
|
"availability_status": True,
|
||||||
@ -218,12 +222,12 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "Peter Nichtlustig",
|
"name": "Peter Nichtlustig",
|
||||||
"postcode": "13337",
|
"postcode": "13337",
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"street": "Waldweg"
|
"street": "Waldweg"
|
||||||
},
|
},
|
||||||
"contacts": [{
|
"contacts": [{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"contacttype": {
|
"contacttype": {
|
||||||
"id": 4,
|
"id": 4,
|
||||||
"name": "Matrix"
|
"name": "Matrix"
|
||||||
@ -231,7 +235,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"content": "@peter:wtf-eg.de"
|
"content": "@peter:wtf-eg.de"
|
||||||
}, {
|
}, {
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"contacttype": {
|
"contacttype": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "E-Mail"
|
"name": "E-Mail"
|
||||||
@ -239,7 +243,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"content": "peter@wtf-eg.de"
|
"content": "peter@wtf-eg.de"
|
||||||
}],
|
}],
|
||||||
"skills": [{
|
"skills": [{
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"skill": {
|
"skill": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "PHP",
|
"name": "PHP",
|
||||||
@ -247,7 +251,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
},
|
},
|
||||||
"level": 5
|
"level": 5
|
||||||
}, {
|
}, {
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"skill": {
|
"skill": {
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "Python",
|
"name": "Python",
|
||||||
@ -256,14 +260,14 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
"level": 3
|
"level": 3
|
||||||
}],
|
}],
|
||||||
"searchtopics": [{
|
"searchtopics": [{
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"skill": {
|
"skill": {
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"name": "PHP",
|
"name": "PHP",
|
||||||
"icon_url": "/skills/1/icon"
|
"icon_url": "/skills/1/icon"
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"skill": {
|
"skill": {
|
||||||
"id": 3,
|
"id": 3,
|
||||||
"name": "Python",
|
"name": "Python",
|
||||||
@ -271,7 +275,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
}
|
}
|
||||||
}],
|
}],
|
||||||
"languages": [{
|
"languages": [{
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"language": {
|
"language": {
|
||||||
"id": "de",
|
"id": "de",
|
||||||
"name": "Deutsch",
|
"name": "Deutsch",
|
||||||
@ -279,7 +283,7 @@ class TestProfileEndpoint(ApiTest):
|
|||||||
},
|
},
|
||||||
"level": 5
|
"level": 5
|
||||||
}, {
|
}, {
|
||||||
"profile_id": 1,
|
"profile_id": profile_id,
|
||||||
"language": {
|
"language": {
|
||||||
"id": "fr",
|
"id": "fr",
|
||||||
"name": "Französisch",
|
"name": "Französisch",
|
||||||
|
@ -11,4 +11,4 @@ with app.app_context():
|
|||||||
config = migrate.get_config()
|
config = migrate.get_config()
|
||||||
command.upgrade(config, "head")
|
command.upgrade(config, "head")
|
||||||
|
|
||||||
serve(app, host="0.0.0.0", port=5000)
|
serve(app, host="0.0.0.0", port=5000, threads=20)
|
||||||
|
Loading…
Reference in New Issue
Block a user