Esempio n. 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['emby']['hostname'] = hostname
    emby = backend.EmbyHandler(config)

    assert emby.api_url(url) == expected
Esempio n. 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

    emby = backend.EmbyHandler(config)

    assert emby.headers == headers
Esempio n. 3
0
def test_password_data(get_token_mock, get_user_mock, create_headers_mock,
                       requests_mock, config):

    emby = backend.EmbyHandler(config)

    assert emby._password_data() == {
        'username': '******',
        'password': '******',
        'passwordMd5': '1d549a7b47c46b7b0a90651360c5574c'
    }
Esempio n. 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

    emby = backend.EmbyHandler(config)

    assert emby.token == token
Esempio n. 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

    emby = backend.EmbyHandler(config)

    assert emby.user_id == user_id
Esempio n. 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.EmbyHandler(config)

    assert 'No Emby user embyuser found' in str(execinfo.value)