ki-backend/ki/test/test_skills_endpoint.py

45 lines
1.3 KiB
Python
Raw Normal View History

2021-06-13 21:41:01 +02:00
from alembic import command
import unittest
from app import app, migrate
from ki.commands import seed
class TestSkillsEndpoint(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()
2021-06-21 22:21:25 +02:00
def test_skills_options(self):
response = self.client.options("/skills")
self.assertEqual(response.status_code, 200)
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
2021-06-13 21:41:01 +02:00
def test_get_skills1(self):
response = self.client.get("/skills?search=p")
self.assertEqual(response.status_code, 200)
2021-06-15 18:08:57 +02:00
self.assertEqual(
{
2021-06-21 16:06:58 +02:00
"skills": [{
"id": 1,
"name": "PHP"
}, {
"id": 3,
"name": "Python"
}]
}, response.json)
2021-06-21 22:21:25 +02:00
self.assertIn("Access-Control-Allow-Origin", response.headers)
self.assertEqual(response.headers["Access-Control-Allow-Origin"], "*")
2021-06-13 21:41:01 +02:00
if __name__ == "main":
unittest.main()