Compare commits
No commits in common. "5dc0f7153d733bcf56d76a8561aeeb4639d3c4d1" and "b09b0722618331ed88ed5b9fa88887ceaa0b59ba" have entirely different histories.
5dc0f7153d
...
b09b072261
@ -6,9 +6,3 @@
|
|||||||
language: system
|
language: system
|
||||||
files: ^.*\.py$
|
files: ^.*\.py$
|
||||||
exclude: ^(migrations).*$
|
exclude: ^(migrations).*$
|
||||||
- id: unittest
|
|
||||||
name: unittest
|
|
||||||
entry: python -m unittest discover ki
|
|
||||||
language: system
|
|
||||||
exclude: .*
|
|
||||||
always_run: true
|
|
||||||
|
@ -13,7 +13,7 @@ class User(db.Model):
|
|||||||
auth_id = Column(String(50), nullable=False, unique=True)
|
auth_id = Column(String(50), nullable=False, unique=True)
|
||||||
profile_id = Column(Integer, ForeignKey("profile.id"), nullable=True)
|
profile_id = Column(Integer, ForeignKey("profile.id"), nullable=True)
|
||||||
|
|
||||||
tokens = relationship("Token", back_populates="user")
|
tokens = relationship("Token", uselist=False, back_populates="user")
|
||||||
profile = relationship("Profile", back_populates="user")
|
profile = relationship("Profile", back_populates="user")
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
from alembic import command
|
|
||||||
import json
|
|
||||||
import unittest
|
|
||||||
|
|
||||||
from app import app, migrate
|
|
||||||
from ki.commands import seed
|
|
||||||
|
|
||||||
|
|
||||||
class TestLoginEndpoint(unittest.TestCase):
|
|
||||||
def setUp(self):
|
|
||||||
app.debug = True
|
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///:memory:"
|
|
||||||
self.client = app.test_client()
|
|
||||||
|
|
||||||
with app.app_context():
|
|
||||||
config = migrate.get_config()
|
|
||||||
command.upgrade(config, "head")
|
|
||||||
|
|
||||||
seed()
|
|
||||||
|
|
||||||
def test_login(self):
|
|
||||||
response1_data = self.login()
|
|
||||||
response2_data = self.login()
|
|
||||||
self.assertNotEqual(response1_data["token"], response2_data["token"])
|
|
||||||
|
|
||||||
def login(self):
|
|
||||||
response = self.client.post("/users/login",
|
|
||||||
data=json.dumps({
|
|
||||||
"username": "peter",
|
|
||||||
"password": "geheim"
|
|
||||||
}),
|
|
||||||
content_type="application/json")
|
|
||||||
self.assertEqual(response.status_code, 200)
|
|
||||||
self.assertIn("token", response.json)
|
|
||||||
return response.json
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "main":
|
|
||||||
unittest.main()
|
|
@ -15,15 +15,12 @@ class TestProfileEndpoint(unittest.TestCase):
|
|||||||
self.client = app.test_client()
|
self.client = app.test_client()
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.drop_all()
|
|
||||||
db.engine.dispose()
|
|
||||||
config = migrate.get_config()
|
config = migrate.get_config()
|
||||||
command.upgrade(config, "head")
|
command.upgrade(config, "head")
|
||||||
|
|
||||||
seed()
|
seed()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
db.drop_all()
|
|
||||||
db.engine.dispose()
|
db.engine.dispose()
|
||||||
|
|
||||||
def test_create_profile(self):
|
def test_create_profile(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user