Пример #1
0
def test_extract_theme_properties(zip_file):
    versions = {
        amo.DEFAULT_WEBEXT_MAX_VERSION,
        amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
        amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
    }
    for version in versions:
        AppVersion.objects.create(application=amo.FIREFOX.id, version=version)
        AppVersion.objects.create(application=amo.ANDROID.id, version=version)

    addon = addon_factory(type=amo.ADDON_STATICTHEME)
    result = utils.extract_theme_properties(addon,
                                            addon.current_version.channel)
    assert result == {}  # There's no file, but it be should safely handled.

    # Add the zip in the right place
    zip_file = os.path.join(settings.ROOT, zip_file)
    copy_stored_file(zip_file, addon.current_version.all_files[0].file_path)
    result = utils.extract_theme_properties(addon,
                                            addon.current_version.channel)
    assert result == {
        "colors": {
            "frame": "#adb09f",
            "tab_background_text": "#000"
        },
        "images": {
            "theme_frame": "weta.png"
        }
    }
Пример #2
0
def test_extract_theme_properties(zip_file):
    versions = {
        amo.DEFAULT_WEBEXT_MAX_VERSION,
        amo.DEFAULT_STATIC_THEME_MIN_VERSION_FIREFOX,
        amo.DEFAULT_STATIC_THEME_MIN_VERSION_ANDROID,
    }
    for version in versions:
        AppVersion.objects.create(application=amo.FIREFOX.id, version=version)
        AppVersion.objects.create(application=amo.ANDROID.id, version=version)

    addon = addon_factory(type=amo.ADDON_STATICTHEME)
    result = utils.extract_theme_properties(
        addon, addon.current_version.channel)
    assert result == {}  # There's no file, but it be should safely handled.

    # Add the zip in the right place
    zip_file = os.path.join(settings.ROOT, zip_file)
    copy_stored_file(zip_file, addon.current_version.all_files[0].file_path)
    result = utils.extract_theme_properties(
        addon, addon.current_version.channel)
    assert result == {
        "colors": {
            "frame": "#adb09f",
            "tab_background_text": "#000"
        },
        "images": {
            "theme_frame": "weta.png"
        }
    }
Пример #3
0
def test_extract_theme_properties():
    addon = addon_factory(type=amo.ADDON_STATICTHEME)
    result = utils.extract_theme_properties(addon,
                                            addon.current_version.channel)
    assert result == {}  # There's no file, but it be should safely handled.

    # Add the zip in the right place
    zip_file = os.path.join(
        settings.ROOT, 'src/olympia/devhub/tests/addons/static_theme.zip')
    copy_stored_file(zip_file, addon.current_version.all_files[0].file_path)
    result = utils.extract_theme_properties(addon,
                                            addon.current_version.channel)
    assert result['colors'] == {"accentcolor": "#adb09f", "textcolor": "#000"}
    assert result['images'] == {
        "headerURL":
        '%s%s//%s/%s/%s' % (settings.MEDIA_URL, 'addons', text_type(
            addon.id), text_type(addon.current_version.id), 'weta.png')
    }
Пример #4
0
def test_extract_theme_properties():
    addon = addon_factory(type=amo.ADDON_STATICTHEME)
    result = utils.extract_theme_properties(
        addon, addon.current_version.channel)
    assert result == {}  # There's no file, but it be should safely handled.

    # Add the zip in the right place
    zip_file = os.path.join(
        settings.ROOT, 'src/olympia/devhub/tests/addons/static_theme.zip')
    copy_stored_file(zip_file, addon.current_version.all_files[0].file_path)
    result = utils.extract_theme_properties(
        addon, addon.current_version.channel)
    assert result == {
        "colors": {
            "accentcolor": "#adb09f",
            "textcolor": "#000"
        },
        "images": {
            "headerURL": "weta.png"
        }
    }