From 1854cf73e3d0fa172e9f0e59ab8479c1a2ceaecb Mon Sep 17 00:00:00 2001 From: Yax <1949284+kianby@users.noreply.github.com> Date: Sat, 28 Aug 2021 15:58:10 +0200 Subject: [PATCH] first api test --- tests/test_api.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/test_api.py diff --git a/tests/test_api.py b/tests/test_api.py new file mode 100644 index 0000000..25c299c --- /dev/null +++ b/tests/test_api.py @@ -0,0 +1,30 @@ +#!/usr/bin/python +# -*- coding: UTF-8 -*- + +import logging + +import pytest + +from stacosys.db import database +from stacosys.interface import api +from stacosys.interface import app + + +@pytest.fixture +def client(): + logger = logging.getLogger(__name__) + db = database.Database() + db.setup(":memory:") + app.config.update(SITE_TOKEN="ETC") + logger.info(f"start interface {api}") + return app.test_client() + + +def test_api_ping(client): + rv = client.get('/ping') + assert rv.data == b"OK" + + +def test_api_count(client): + rv = client.get('/comments/count') + assert b'{"count":0}\n' in rv.data