예제 #1
0
def test_parse_response(response, correct):
    """Test the parse_response function"""
    music_service = Mock()
    music_service.desc = "DESC"
    results = data_structures.parse_response(music_service, response, "albums")

    # Check the search result metadata
    response_data = response[correct["type"]]
    assert results.number_returned == response_data["count"]
    assert results.search_type == "albums"

    # Check the result
    assert len(results) == correct["number_of_results"]
    klass = data_structures.get_class(correct["class_key"])
    for result in results:
        assert isinstance(result, klass)
        assert result.music_service is music_service
def test_parse_response(response, correct):
    """Test the parse_response function"""
    music_service = Mock()
    music_service.desc = 'DESC'
    results = data_structures.parse_response(music_service, response, 'albums')

    # Check the search result metadata
    response_data = response[correct['type']]
    assert results.number_returned == response_data['count']
    assert results.search_type == 'albums'

    # Check the result
    assert len(results) == correct['number_of_results']
    klass = data_structures.get_class(correct['class_key'])
    for result in results:
        assert isinstance(result, klass)
        assert result.music_service is music_service
def test_parse_response(response, correct):
    """Test the parse_response function"""
    music_service = Mock()
    music_service.desc = 'DESC'
    results = data_structures.parse_response(music_service, response, 'albums')

    # Check the search result metadata
    response_data = response[correct['type']]
    assert results.number_returned == response_data['count']
    assert results.search_type == 'albums'

    # Check the result
    assert len(results) == correct['number_of_results']
    klass = data_structures.get_class(correct['class_key'])
    for result in results:
        assert isinstance(result, klass)
        assert result.music_service is music_service
예제 #4
0
def test_parse_response_bad_type():
    """Test parse reponse bad code"""
    with pytest.raises(ValueError) as exp:
        data_structures.parse_response(None, {}, "albums")
    print(exp)
def test_parse_response_bad_type():
    """Test parse reponse bad code"""
    with pytest.raises(ValueError) as exp:
        data_structures.parse_response(None, {}, 'albums')
    print(exp)