示例#1
0
def test_api_url(password_data_mock, get_user_mock, create_header_mock,
                 get_token_mock, config, hostname, url, expected):
    get_user_mock.return_value = [{'Id': 'foo'}]

    config['jellyfin']['hostname'] = hostname
    jellyfin = backend.JellyfinHandler(config)

    assert jellyfin.api_url(url) == expected
示例#2
0
def test_create_headers(get_token_mock, get_user_mock, password_data_mock,
                        requests_mock, token, headers, config):

    get_user_mock.return_value = [{'Id': 123}]
    get_token_mock.return_value = token

    jellyfin = backend.JellyfinHandler(config)

    assert jellyfin.headers == headers
示例#3
0
def test_password_data(get_token_mock, get_user_mock, create_headers_mock,
                       requests_mock, config):

    jellyfin = backend.JellyfinHandler(config)

    assert jellyfin._password_data() == {
        'username': '******',
        'password': '******',
        'passwordMd5': '1d549a7b47c46b7b0a90651360c5574c'
    }
示例#4
0
def test_get_token(get_user_mock, password_data_mock, create_headers_mock,
                   post_mock, data, token, config):

    mock_response = mock.Mock()
    with open(data, 'r') as f:
        mock_response.json.return_value = json.load(f)

    post_mock.return_value = mock_response

    jellyfin = backend.JellyfinHandler(config)

    assert jellyfin.token == token
示例#5
0
def test_get_user(password_mock, create_headers_mock, get_tocken_mock,
                  get_mock, data, user_id, config):

    mock_response = mock.Mock()
    with open(data, 'r') as f:
        mock_response.json.return_value = json.load(f)

    get_mock.return_value = mock_response

    jellyfin = backend.JellyfinHandler(config)

    assert jellyfin.user_id == user_id
示例#6
0
def test_get_user_exception(password_mock, create_headers_mock,
                            get_tocken_mock, get_mock, config):

    mock_response = mock.Mock()
    with open('tests/data/get_user1.json', 'r') as f:
        mock_response.json.return_value = json.load(f)

    get_mock.return_value = mock_response

    with pytest.raises(Exception) as execinfo:
        backend.JellyfinHandler(config)

    assert 'No Jellyfin user jellyfinuser found' in str(execinfo.value)