File: query_test.py

package info (click to toggle)
python-pook 2.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 672 kB
  • sloc: python: 3,558; makefile: 13
file content (27 lines) | stat: -rw-r--r-- 573 bytes parent folder | download
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
from urllib.request import urlopen

import pytest

import pook
from pook.exceptions import PookNoMatches


@pytest.fixture
def URL(httpbin):
    return f"{httpbin.url}/status/404"


@pytest.mark.pook(allow_pending_mocks=True)
def test_param_exists_empty_disallowed(URL):
    pook.get(URL).param_exists("x").reply(200)

    with pytest.raises(PookNoMatches):
        urlopen(f"{URL}?x")


@pytest.mark.pook
def test_param_exists_empty_allowed(URL):
    pook.get(URL).param_exists("x", allow_empty=True).reply(200)

    res = urlopen(f"{URL}?x")
    assert res.status == 200