File: unicode_test.py

package info (click to toggle)
pylast 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 296 kB
  • sloc: python: 2,564; makefile: 10
file content (30 lines) | stat: -rw-r--r-- 718 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
# -*- coding: utf-8 -*-
import mock
import pytest
import six

import pylast


def mock_network():
    return mock.Mock(_get_ws_auth=mock.Mock(return_value=("", "", "")))


@pytest.mark.parametrize(
    "artist",
    [
        u"\xe9lafdasfdsafdsa",
        u"ééééééé",
        pylast.Artist(u"B\xe9l", mock_network()),
        "fdasfdsafsaf not unicode",
    ],
)
def test_get_cache_key(artist):
    request = pylast._Request(mock_network(), "some_method", params={"artist": artist})
    request._get_cache_key()


@pytest.mark.parametrize("obj", [pylast.Artist(u"B\xe9l", mock_network())])
def test_cast_and_hash(obj):
    assert type(six.text_type(obj)) is six.text_type
    assert isinstance(hash(obj), int)