seed entire profile

This commit is contained in:
2021-06-26 10:51:39 +02:00
parent 09669cf369
commit ace1b1ed85
7 changed files with 112 additions and 64 deletions

View File

@ -2,8 +2,8 @@ from alembic import command
import json
import unittest
from app import app, migrate
from ki.commands import seed
from app import app, db, migrate
from ki.actions import seed
class TestLoginEndpoint(unittest.TestCase):
@ -16,7 +16,11 @@ class TestLoginEndpoint(unittest.TestCase):
config = migrate.get_config()
command.upgrade(config, "head")
seed()
seed(True)
def tearDown(self):
db.drop_all()
db.engine.dispose()
def test_login(self):
response1_data = self.login()

View File

@ -3,8 +3,8 @@ import unittest
import json
from app import app, db, migrate
from ki.commands import seed
from ki.models import Profile, User
from ki.actions import seed
from ki.models import User
class TestProfileEndpoint(unittest.TestCase):
@ -15,22 +15,16 @@ class TestProfileEndpoint(unittest.TestCase):
self.client = app.test_client()
with app.app_context():
db.drop_all()
db.engine.dispose()
config = migrate.get_config()
command.upgrade(config, "head")
seed()
seed(True)
def tearDown(self):
db.drop_all()
db.engine.dispose()
def test_create_profile(self):
user = User(auth_id="peter")
db.session.add(user)
db.session.commit()
login_data = {"username": "peter", "password": "geheim"}
login_response = self.client.post("/users/login",
data=json.dumps(login_data),
@ -62,15 +56,6 @@ class TestProfileEndpoint(unittest.TestCase):
self.assertEqual("Hallo", profile.freetext)
def test_get_profile(self):
user = User(auth_id="peter")
db.session.add(user)
profile = Profile(user=user)
profile.nickname = "Popeter"
db.session.add(profile)
db.session.commit()
login_data = {"username": "peter", "password": "geheim"}
login_response = self.client.post("/users/login",
data=json.dumps(login_data),
@ -89,10 +74,10 @@ class TestProfileEndpoint(unittest.TestCase):
self.assertEqual(
response.json, {
"profile": {
"freetext": "",
"nickname": "Popeter",
"pronouns": "",
"volunteerwork": ""
"freetext": "Ich mag Kaffee",
"nickname": "peternichtlustig",
"pronouns": "Herr Dr. Dr.",
"volunteerwork": "Gartenverein"
}
})

View File

@ -1,8 +1,8 @@
from alembic import command
import unittest
from app import app, migrate
from ki.commands import seed
from app import app, db, migrate
from ki.actions import seed
class TestSkillsEndpoint(unittest.TestCase):
@ -15,7 +15,11 @@ class TestSkillsEndpoint(unittest.TestCase):
config = migrate.get_config()
command.upgrade(config, "head")
seed()
seed(True)
def tearDown(self):
db.drop_all()
db.engine.dispose()
def test_skills_options(self):
response = self.client.options("/skills")