コード例 #1
0
def test_get_class():
    """Test the get_class function"""
    # Test core functionality for base class MediaMetadata
    cls = data_structures.get_class("MediaMetadataTrack")
    assert cls.__name__ == "MSTrack"
    assert issubclass(cls, data_structures.MediaMetadata)

    # Test core functionality for base class Mediacolection
    cls = data_structures.get_class("MediaCollectionArtist")
    assert cls.__name__ == "MSArtist"
    assert issubclass(cls, data_structures.MediaCollection)

    # Test the caching function
    cls2 = data_structures.get_class("MediaCollectionArtist")
    assert cls is cls2

    # Asking for bad class should raise KeyError
    with pytest.raises(KeyError):
        cls = data_structures.get_class("Nonsense")
コード例 #2
0
def test_get_class():
    """Test the get_class function"""
    # Test core functionality for base class MediaMetadata
    cls = data_structures.get_class('MediaMetadataTrack')
    assert cls.__name__ == 'MSTrack'
    assert issubclass(cls, data_structures.MediaMetadata)

    # Test core functionality for base class Mediacolection
    cls = data_structures.get_class('MediaCollectionArtist')
    assert cls.__name__ == 'MSArtist'
    assert issubclass(cls, data_structures.MediaCollection)

    # Test the caching function
    cls2 = data_structures.get_class('MediaCollectionArtist')
    assert cls is cls2

    # Asking for bad class should raise KeyError
    with pytest.raises(KeyError):
        cls = data_structures.get_class('Nonsense')
コード例 #3
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
コード例 #4
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
コード例 #5
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