File: test_media_types.py

package info (click to toggle)
python-whitenoise 6.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 472 kB
  • sloc: python: 2,040; makefile: 132; javascript: 10
file content (29 lines) | stat: -rw-r--r-- 843 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
from __future__ import annotations

from whitenoise.media_types import MediaTypes


def test_matched_filename():
    result = MediaTypes().get_type("static/apple-app-site-association")
    assert result == "application/pkc7-mime"


def test_matched_filename_cased():
    result = MediaTypes().get_type("static/Apple-App-Site-Association")
    assert result == "application/pkc7-mime"


def test_matched_extension():
    result = MediaTypes().get_type("static/app.js")
    assert result == "text/javascript"


def test_unmatched_extension():
    result = MediaTypes().get_type("static/app.example-unmatched")
    assert result == "application/octet-stream"


def test_extra_types():
    types = MediaTypes(extra_types={".js": "application/javascript"})
    result = types.get_type("static/app.js")
    assert result == "application/javascript"