Пример #1
0
def test_get_download_url(HttpMock):
    client = init_client()
    member_id = 'bacba2b288328238bcbac'
    track_format = 'mp3'
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(
        textwrap.dedent(
            """<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>"""
        ) % locals())

    track = Track._from_xml(track_xml, client)

    download_url = track.get_download_url(track_format, member_id)
    download_url_template = client.config.download_url

    format_identifier = client.config.get_format_identifier(track_format)
    expected_url = download_url_template.replace('{memberaccountid}', member_id).\
                                         replace('{id}', track_id).\
                                         replace('{trackformat}', format_identifier)
    assert download_url == expected_url, 'url: %s != expected: %s' % (
        download_url, expected_url)
Пример #2
0
def test_track_dict():
    client = init_client()
    track_id = '17376d36f309f18d'
    track_xml = ET.fromstring(textwrap.dedent("""<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="Guerilla Pop" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>""") % locals())

    track = Track._from_xml(track_xml, client)
    track_dict = track.as_dict()
    assert track_dict['id'] == track_id
Пример #3
0
def test_track_dict():
    client = init_client()
    track_id = '17376d36f309f18d'
    track_xml = ET.fromstring(
        textwrap.dedent(
            """<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="Guerilla Pop" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>"""
        ) % locals())

    track = Track._from_xml(track_xml, client)
    track_dict = track.as_dict()
    assert track_dict['id'] == track_id
Пример #4
0
def test_get_download_url_missing_format(HttpMock):
    client = init_client()
    member_id = 'bacba2b288328238bcbac'
    track_format = 'BAD-FORMAT'
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(textwrap.dedent("""<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>""") % locals())

    track = Track._from_xml(track_xml, client)

    download_url = track.get_download_url(track_format, member_id)
Пример #5
0
def test_get_download_url_missing_format(HttpMock):
    client = init_client()
    member_id = 'bacba2b288328238bcbac'
    track_format = 'BAD-FORMAT'
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(
        textwrap.dedent(
            """<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>"""
        ) % locals())

    track = Track._from_xml(track_xml, client)

    download_url = track.get_download_url(track_format, member_id)
Пример #6
0
def test_get_waveform_url(HttpMock):
    client = init_client()
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(textwrap.dedent("""<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>""") % locals())

    track = Track._from_xml(track_xml, client)

    width = 200
    height = 300
    waveform_url = track.get_waveform_url(width, height)

    waveform_url_template = client.config.waveform_url
    expected_url = waveform_url_template.replace('{id}', track_id).replace('{width}', str(width)).replace('{height}', str(height))
    assert waveform_url == expected_url
Пример #7
0
def test_get_download_url(HttpMock):
    client = init_client()
    member_id = 'bacba2b288328238bcbac'
    track_format = 'mp3'
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(textwrap.dedent("""<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>""") % locals())

    track = Track._from_xml(track_xml, client)

    download_url = track.get_download_url(track_format, member_id)
    download_url_template = client.config.download_url

    format_identifier = client.config.get_format_identifier(track_format)
    expected_url = download_url_template.replace('{memberaccountid}', member_id).\
                                         replace('{id}', track_id).\
                                         replace('{trackformat}', format_identifier)
    assert download_url == expected_url, 'url: %s != expected: %s' % (download_url, expected_url)
Пример #8
0
def test_get_waveform_url(HttpMock):
    client = init_client()
    track_id = '17376d36f309f18d'
    track_name = 'Guerilla Pop'
    track_xml = ET.fromstring(
        textwrap.dedent(
            """<track tracknumber="1" time="02:50" lengthseconds="170" comment="Make sure you’re down
                                                  the front for this fiery Post Punk workout." composer="&quot;S. Milton, J. Wygens&quot;"
                                                  publisher="" name="%(track_name)s" albumid="1c5f47572d9152f3" id="%(track_id)s"
                                                  keywords="" displaytitle="Guerilla Pop" genre="Pop / Rock" tempo="" instrumentation=""
                                                  bpm="" mixout="" frequency="44100" bitrate="1411" dateingested="2008-05-15 06:08:18"/>"""
        ) % locals())

    track = Track._from_xml(track_xml, client)

    width = 200
    height = 300
    waveform_url = track.get_waveform_url(width, height)

    waveform_url_template = client.config.waveform_url
    expected_url = waveform_url_template.replace('{id}', track_id).replace(
        '{width}', str(width)).replace('{height}', str(height))
    assert waveform_url == expected_url