File: test_fixtures.py

package info (click to toggle)
pytest-flask 1.3.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 280 kB
  • sloc: python: 553; makefile: 161; sh: 5
file content (32 lines) | stat: -rwxr-xr-x 1,042 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
28
29
30
31
32
import pytest
from flask import request
from flask import url_for


class TestFixtures:
    def test_config_access(self, config):
        assert config["SECRET_KEY"] == "42"

    def test_client(self, client):
        assert client.get(url_for("ping")).status == "200 OK"

    def test_accept_json(self, accept_json):
        assert accept_json == [("Accept", "application/json")]

    def test_accept_jsonp(self, accept_jsonp):
        assert accept_jsonp == [("Accept", "application/json-p")]

    def test_accept_mimetype(self, accept_mimetype):
        mimestrings = [[("Accept", "application/json")], [("Accept", "text/html")]]
        assert accept_mimetype in mimestrings

    def test_accept_any(self, accept_any):
        mimestrings = [[("Accept", "*")], [("Accept", "*/*")]]
        assert accept_any in mimestrings


@pytest.mark.usefixtures("client_class")
class TestClientClass:
    def test_client_attribute(self):
        assert hasattr(self, "client")
        assert self.client.get(url_for("ping")).json == {"ping": "pong"}