Exemple #1
0
def track_title(tags, exclude_tags=[]):
    """
    >>> import copy
    >>> track_title(_test_tags)
    'Macross: Dynamite - Opening, Op1 - Dynamite Explosion, キ'
    >>> track_title(_test_tags, exclude_tags=['from:macross'])
    'Dynamite - Opening, Op1 - Dynamite Explosion, キ'
    >>> _test_tags_artist = copy.copy(_test_tags)
    >>> _test_tags_artist['category'] = ['jpop','anime']
    >>> track_title(_test_tags_artist)
    'Firebomber - Dynamite Explosion, キ'
    """
    from_exclude = list(filter(lambda t: t.startswith('from:'), exclude_tags))
    from_include = [from_exclude.pop().split(':').pop().strip()
                    ] if from_exclude else []
    exclude_tags = [tag.split(':')[0] for tag in exclude_tags
                    ]  # setup initial exclude tags from passed args
    if substring_in(
            tags.get('title'), tags.get('from')
    ):  # if 'title' is in 'from' - exclude title as it is a duplicate
        exclude_tags.append('title')
    title_tags = title_tags_for_category.get(
        tags.get('category', 'DEFAULT')[0], title_tags_for_category['DEFAULT']
    )  # get tags to use in the constuction of this category
    tags_to_use = from_include + list(
        filter(lambda t: t not in exclude_tags,
               title_tags))  # remove exclude tags from tag list
    return " - ".join(
        filter(None,
               (tag_hireachy(tags, tag) for tag in tags_to_use))).title()
Exemple #2
0
def test_static(app, queue):
    def external_links(path):
        """ Extract list of externals from page """
        soup = BeautifulSoup(app.get(path).text)
        scripts = {script['src'] for script in soup.find_all('script')}
        links = {link['href'] for link in soup.find_all('link')}
        return scripts | links

    static_files = set()
    with admin_rights(app, queue):
        for path in ('/', f'/queue/{queue}/track_list'):
            static_files |= external_links(path)

    # Request each external (no 404's should be found)
    for static_file in static_files:
        app.get(static_file)

    # Check we have all the known external files lists
    expected_externals = (
        'cssreset-min.css',
        'jquery.mobile.min.css',
        'main.css',
        'modernizer.custom.js',
        'jquery.min.js',
        'jquery.mobile-extras.js',
        'jquery.mobile.min.js',
        'jquery.cookie.js',
        'lib.js',
        'karakara.js',
        'favicon.ico',
        'print_list.css',
    )
    for external in expected_externals:
        assert substring_in(external, static_files)
Exemple #3
0
def test_static(app):

    def external_links(path):
        """ Extract list of externals from page """
        soup = BeautifulSoup(app.get(path).text)
        scripts = {script['src'] for script in soup.find_all('script')}
        links = {link['href'] for link in soup.find_all('link')}
        return scripts | links
    static_files = set()
    with admin_rights(app):
        for path in ('/', '/track_list'):
            static_files |= external_links(path)

    # Request each external (no 404's should be found)
    for static_file in static_files:
        app.get(static_file)

    # Check we have all the known external files lists
    expected_externals = (
        'cssreset-min.css',
        'jquery.mobile.min.css',
        'main.css',
        'modernizer.custom.js',
        'jquery.min.js',
        'jquery.mobile-extras.js',
        'jquery.mobile.min.js',
        'jquery.cookie.js',
        'lib.js',
        'karakara.js',
        'favicon.ico',
        'print_list.css',
    )
    for external in expected_externals:
        assert substring_in(external, static_files)
Exemple #4
0
def track_title(tags, exclude_tags=[]):
    """
    >>> import copy
    >>> track_title(_test_tags)
    'Macross: Dynamite - Opening, Op1 - Dynamite Explosion, キ'
    >>> track_title(_test_tags, exclude_tags=['from:macross'])
    'Dynamite - Opening, Op1 - Dynamite Explosion, キ'
    >>> _test_tags_artist = copy.copy(_test_tags)
    >>> _test_tags_artist['category'] = ['jpop','anime']
    >>> track_title(_test_tags_artist)
    'Firebomber - Dynamite Explosion, キ'
    """
    from_exclude = list(filter(lambda t: t.startswith('from:'), exclude_tags))
    from_include = [from_exclude.pop().split(':').pop().strip()] if from_exclude else []
    exclude_tags = [tag.split(':')[0] for tag in exclude_tags]  # setup initial exclude tags from passed args
    if substring_in(tags.get('title'), tags.get('from')):  # if 'title' is in 'from' - exclude title as it is a duplicate
        exclude_tags.append('title')
    title_tags = title_tags_for_category.get(tags.get('category', 'DEFAULT')[0], title_tags_for_category['DEFAULT'])  # get tags to use in the constuction of this category
    tags_to_use = from_include + list(filter(lambda t: t not in exclude_tags, title_tags))  # remove exclude tags from tag list
    return " - ".join(filter(None, (tag_hireachy(tags, tag) for tag in tags_to_use))).title()