File: test_duckpy_basic.py

package info (click to toggle)
python-duckpy 3.2.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 124 kB
  • sloc: python: 118; sh: 15; makefile: 3
file content (34 lines) | stat: -rw-r--r-- 897 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import asyncio
from duckpy import AsyncClient
from duckpy import Client

def test_functional():
     client = Client()
     results = client.search("Python Wikipedia")
     # Assert first result title is not empty
     assert results[0]['title'] != ""

     # Assert first result URL is not empty
     assert results[0]['url'] != ""

     # Prints first result description
     assert results[0]['description'] != ""


async def get_asyncio_results():
    client = AsyncClient()
    results = await client.search("Debian")

    # Assert first result title is not empty
    assert results[0]['title'] != ""

    # Assert first result URL is not empty
    assert results[0]['url'] != ""

    # Assert first result description is not empty
    assert results[0]['description'] != ""


def test_asyncio_results():
    loop = asyncio.get_event_loop()
    loop.run_until_complete(get_asyncio_results())