Skip to content

Commit

Permalink
adding tests for routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mfenner committed Oct 7, 2023
1 parent b2c2926 commit 5a9957f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test-routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rogue_scholar_api import app
import pytest # noqa: F401
import pytest_asyncio # noqa: F401
import pydash as py_ # noqa: F401

pytestmark = pytest.mark.asyncio

Expand All @@ -22,3 +23,24 @@ async def test_blogs_route():
assert len(result) == 60
assert result[0]["title"] == "A blog by Ross Mounce"
assert result[0]["slug"] == "rossmounce"


async def test_single_blog_route():
test_client = app.test_client()
response = await test_client.get("/blogs/andrewheiss")
assert response.status_code == 200
result = await response.get_json()
assert result["title"] == "Andrew Heiss's blog"
assert result["feed_url"] == "https://www.andrewheiss.com/atom.xml"


async def test_posts_route():
test_client = app.test_client()
response = await test_client.get("/posts")
assert response.status_code == 200
result = await response.get_json()
posts = result["hits"]
assert len(posts) == 10
post = py_.get(posts, "[0].document")
assert post["title"] == "¿Qué libros científicos publicamos?"
assert post["doi"] == "https://doi.org/10.59350/sfzv4-xdb68"

0 comments on commit 5a9957f

Please sign in to comment.