aio-libs/aiohttp-demos

Tests for demo polls app

gyermolenko opened this issue · 3 comments

I would like to update/fix tests for demo polls app.
Let's start with simplest test scenarios:

  1. get 'index' view (can be done with or wo test client)
  2. post:
    • count choices for question 1 (smth like res = await conn.execute(choice.count()))
    • post vote
    • recount choices (assert is it +1)

But there are a couple of questions I need to clarify first.

  • pytest (or pytest and unittest comparison)?
  • DB initialization: setup/teardown, install.sh or migration
  • do we need db fixture?

Could anyone with experience in testing async code share his view or examples I can look at? Thanks.

  1. pytest-asyncio please
  2. Migration would be nice but we don't have migrations
  3. Yes, sure. In my dream the fixture should run Postgres in docker as we do for aiopg. No need for different PG server versions, the latest tag would be fine.

For examples you could just look on aiohttp test suite, files with functional in file name.

trying to take care of this issue in #9

fixed in #9