File: test_blurhash.py

package info (click to toggle)
python-mastodon 2.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,836 kB
  • sloc: python: 9,438; makefile: 206; sql: 98; sh: 27
file content (25 lines) | stat: -rw-r--r-- 773 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
import pytest

import mastodon.compat
if not mastodon.compat.IMPL_HAS_BLURHASH:
    pytest.skip("blurhash dependencies missing, skipping blurhash tests", allow_module_level=True)

def test_blurhash_decode(api):
    fake_media_dict = {
        'width': 320,
        'height': 240,
        'blurhash': '=~NdOWof1PbIPUXSvgbI$f'
    }
    decoded_image = api.decode_blurhash(fake_media_dict)
    assert len(decoded_image) == 9 * 16
    assert len(decoded_image[0]) == 16
    
    decoded_image_2 = api.decode_blurhash(
        fake_media_dict, 
        out_size = (fake_media_dict["width"], fake_media_dict["height"]),
        size_per_component = False,
        return_linear = False
    )
    assert len(decoded_image_2) == 240
    assert len(decoded_image_2[0]) == 320