Пример #1
0
def extension(**kw):
    global extension_counter
    extension_counter += 1
    slug = kw.get('slug', 'add-on-%d' % extension_counter)
    uuid = unicode(uuid4()).replace('-', '')

    data = {
        'id': SPECIAL_SLUGS_TO_IDS.get(slug, extension_counter),
        'author': random.choice(AUTHORS),
        'description': {
            'en-US': escape(kw.get('description', rand_text(20))),
        },
        'device_types': [
            'firefoxos'
        ],
        'disabled': False,
        'icons': {
            '64': '%s/media/img/mkt/logos/64.png' % CDN_URL,
            '128': '%s/media/img/mkt/logos/128.png' % CDN_URL,
        },
        'last_updated': '2015-10-30T15:50:40',
        'latest_public_version': {
            'id': 294,
            'created': '2015-10-29T13:53:12',
            'download_url': '/extension/%s/42/extension-0.1.zip' % uuid,
            'reviewer_mini_manifest_url':
                '/extension/reviewers/%s/42/manifest.json' % uuid,
            'unsigned_download_url':
                '/downloads/extension/unsigned/%s/42/extension-0.1.zip' % uuid,
            'size': 19062,
            'status': 'public',
            'version': '0.1'
        },
        'mini_manifest_url': '/extension/%s/manifest.json' % uuid,
        'name': {
            'en-US': text('Add-on %d' % extension_counter),
        },
        'slug': slug,
        'status': 'public',
        'uuid': uuid,
    }
    data = dict(data, **kw)
    return data
Пример #2
0
def app(**kw):
    """
    In the API everything here except `user` should be serialized and keyed off
    counter:region:locale.
    """
    global counter
    counter += 1

    slug = kw.get('slug', 'app-%d' % counter)

    data = {
        'id': SPECIAL_SLUGS_TO_IDS.get(slug, counter),
        'author': random.choice(AUTHORS),
        'categories': ['social', 'games'],
        'content_ratings': {
            'body': 'generic',
            'rating': '12',
            'descriptors': ['scary', 'lang', 'drugs'],
            'interactives': ['users-interact', 'shares-info']
        },
        'current_version': text('%d.0' % int(random.random() * 20)),
        'description': {'en-US': escape(kw.get('description',
                                               rand_text(100)))},
        'device_types': ['desktop', 'firefoxos', 'android-mobile',
                         'android-tablet'],
        'file_size': 12345,
        'homepage': 'http://marketplace.mozilla.org/',
        'icons': {
            64: '/media/img/logos/64.png'
        },
        'is_packaged': slug == 'packaged' or rand_bool(),
        'manifest_url':
            'http://%s%s.testmanifest.com/manifest.webapp' %
            (rand_text(1), random.randint(1, 50000)),  # Minifest if packaged
        'name': text('App %d' % counter),
        'notices': random.choice(MESSAGES),
        'previews': [_app_preview() for i in range(4)],
        'privacy_policy': kw.get('privacy_policy', rand_text()),
        'public_stats': False,
        'slug': slug,
        'ratings': {
            'average': random.random() * 4 + 1,
            'count': int(random.random() * 500),
        },
        'release_notes': kw.get('release_notes', rand_text(100)),
        'support_email': text('support@%s.com' % slug),
        'support_url': text('support.%s.com' % slug),
        'upsell': False,
    }

    has_price = rand_bool()
    price = '%.2f' % (random.random() * 10)
    if slug == 'free':
        has_price = False
    elif slug == 'paid':
        has_price = True
        price = '0.99'

    if slug == 'upsell':
        data['upsell'] = {
            'id': random.randint(1, 10000),
            'name': rand_text(),
            'icon_url': '/media/img/logos/firefox-256.png',
            'app_slug': 'upsold',
            'resource_uri': '/api/v1/fireplace/app/%s/' % 'upsold',
        }

    if has_price:
        data.update(price=price, price_locale='$%s' % price)
    else:
        data.update(price=None, price_locale='$0.00')

    data['payment_required'] = has_price

    if slug == 'packaged':
        data['current_version'] = '1.0'

    if slug in SPECIAL_APP_SLUGS:
        data['name'] = string.capwords(slug.replace('_', ' '))

    data.update(app_user_data(slug))

    return dict(data, **kw)
Пример #3
0
def app(**kw):
    """
    In the API everything here except `user` should be serialized and keyed off
    counter:region:locale.
    """
    global counter
    counter += 1

    num_previews = kw.get('num_previews', 4)
    slug = kw.get('slug', 'app-%d' % counter)

    data = {
        'id': SPECIAL_SLUGS_TO_IDS.get(slug, counter),
        'author': random.choice(AUTHORS),
        'categories': ['social', 'games'],
        'content_ratings': {
            'body': 'generic',
            'rating': '12',
            'descriptors': ['scary', 'lang', 'drugs'],
            'interactives': ['users-interact', 'shares-info']
        },
        'current_version': text('%d.0' % int(random.random() * 20)),
        'description': {'en-US': escape(kw.get('description',
                                               rand_text(100)))},
        'device_types': ['desktop', 'firefoxos', 'android-mobile',
                         'android-tablet', 'firefoxos-tv'],
        'file_size': 12345,
        'homepage': 'http://marketplace.mozilla.org/',
        'icons': {
            64: '/media/img/logos/64.png'
        },
        'is_packaged': slug == 'packaged' or rand_bool(),
        'last_updated': rand_datetime(),
        'manifest_url':
            # Minifest if packaged
            'http://%s.testmanifest.com/manifest.webapp' % slug,
        'name': text('App %d' % counter),
        'notices': random.choice(MESSAGES),
        'premium_type': 'free',
        'previews': [_app_preview() for i in range(num_previews)],
        'price': None,
        'price_locale': '$0.00',
        'promo_images': {
            'small': random.choice(PROMO_IMAGES),
            'large': random.choice(PROMO_IMAGES),
        },
        'privacy_policy': kw.get('privacy_policy', rand_text()),
        'public_stats': False,
        'slug': slug,
        'ratings': {
            'average': random.random() * 4 + 1,
            'count': int(random.random() * 500),
        },
        'release_notes': kw.get('release_notes', rand_text(100)),
        'support_email': text('support@%s.com' % slug),
        'support_url': text('support.%s.com' % slug),
        'tv_featured': random.choice([True, False]),
        'upsell': False,
    }

    data.update(app_user_data(slug))
    data = dict(data, **kw)

    # Special apps.
    if slug == 'paid':
        data.update(
            price=3.50,
            price_locale='$3.50',
            payment_required=True
        )
    elif slug == 'upsell':
        data['upsell'] = {
            'id': random.randint(1, 10000),
            'name': rand_text(),
            'icon_url': '/media/img/logos/firefox-256.png',
            'app_slug': 'upsold',
            'resource_uri': '/api/v1/fireplace/app/%s/' % 'upsold',
        }
    elif slug == 'packaged':
        data['current_version'] = '1.0'
    elif slug == 'unrated':
        data['ratings'] = {
            'average': 0,
            'count': 0,
        }
    elif slug == 'tracking':
        data['id'] = 1234
        data['author'] = 'Tracking'
        data['name'] = 'Tracking'
    elif slug.startswith('num-previews-'):
        data['previews'] = [_app_preview() for x in
                            range(int(slug.split('num-previews-')[1]))]

    if slug in SPECIAL_APP_SLUGS or slug.startswith('num-previews-'):
        data['name'] = string.capwords(
            slug.replace('_', ' ').replace('-', ' '))

    return data
def app(**kw):
    """
    In the API everything here except `user` should be serialized and keyed off
    counter:region:locale.
    """
    global counter
    counter += 1

    num_previews = kw.get("num_previews", 4)
    slug = kw.get("slug", "app-%d" % counter)

    data = {
        "id": SPECIAL_SLUGS_TO_IDS.get(slug, counter),
        "author": random.choice(AUTHORS),
        "categories": ["social", "games"],
        "content_ratings": {
            "body": "generic",
            "rating": "12",
            "descriptors": ["scary", "lang", "drugs"],
            "interactives": ["users-interact", "shares-info"],
        },
        "current_version": text("%d.0" % int(random.random() * 20)),
        "description": {"en-US": escape(kw.get("description", rand_text(100)))},
        "device_types": ["desktop", "firefoxos", "android-mobile", "android-tablet"],
        "file_size": 12345,
        "homepage": "http://marketplace.mozilla.org/",
        "icons": {64: "/media/img/logos/64.png"},
        "is_packaged": slug == "packaged" or rand_bool(),
        "last_updated": rand_datetime(),
        "manifest_url":
        # Minifest if packaged
        "http://%s.testmanifest.com/manifest.webapp" % slug,
        "name": text("App %d" % counter),
        "notices": random.choice(MESSAGES),
        "premium_type": "free",
        "previews": [_app_preview() for i in range(num_previews)],
        "price": None,
        "price_locale": "$0.00",
        "privacy_policy": kw.get("privacy_policy", rand_text()),
        "public_stats": False,
        "slug": slug,
        "ratings": {"average": random.random() * 4 + 1, "count": int(random.random() * 500)},
        "release_notes": kw.get("release_notes", rand_text(100)),
        "support_email": text("support@%s.com" % slug),
        "support_url": text("support.%s.com" % slug),
        "upsell": False,
    }

    data.update(app_user_data(slug))
    data = dict(data, **kw)

    # Special apps.
    if slug == "paid":
        data.update(price=3.50, price_locale="$3.50", payment_required=True)
    elif slug == "upsell":
        data["upsell"] = {
            "id": random.randint(1, 10000),
            "name": rand_text(),
            "icon_url": "/media/img/logos/firefox-256.png",
            "app_slug": "upsold",
            "resource_uri": "/api/v1/fireplace/app/%s/" % "upsold",
        }
    elif slug == "packaged":
        data["current_version"] = "1.0"
    elif slug == "unrated":
        data["ratings"] = {"average": 0, "count": 0}
    elif slug == "tracking":
        data["id"] = 1234
        data["author"] = "Tracking"
        data["name"] = "Tracking"
    elif slug.startswith("num-previews-"):
        data["previews"] = [_app_preview() for x in range(int(slug.split("num-previews-")[1]))]

    if slug in SPECIAL_APP_SLUGS or slug.startswith("num-previews-"):
        data["name"] = string.capwords(slug.replace("_", " ").replace("-", " "))

    return data