2019-05-31 02:18:56 +03:00
|
|
|
from addons_daily.utils.telemetry_data import *
|
|
|
|
from addons_daily.addons_report import expand_addons
|
|
|
|
from addons_daily.utils.helpers import is_same
|
|
|
|
from pyspark.sql.types import *
|
|
|
|
from pyspark.sql import Row
|
|
|
|
import pytest
|
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
BASE_DATE = "20190515"
|
|
|
|
|
|
|
|
|
|
|
|
def df_to_json(df):
|
|
|
|
return [i.asDict() for i in df.collect()]
|
|
|
|
|
|
|
|
|
2019-06-04 20:32:25 +03:00
|
|
|
def load_test_data(prefix, spark):
|
2019-05-31 02:18:56 +03:00
|
|
|
root = os.path.dirname(__file__)
|
2019-06-04 20:32:25 +03:00
|
|
|
schema_path = os.path.join(root, "resources", "{}_schema.json".format(prefix))
|
2019-05-31 02:18:56 +03:00
|
|
|
with open(schema_path) as f:
|
|
|
|
d = json.load(f)
|
|
|
|
schema = StructType.fromJson(d)
|
2019-06-04 20:32:25 +03:00
|
|
|
rows_path = os.path.join(root, "resources", "{}.json".format(prefix))
|
2019-05-31 02:18:56 +03:00
|
|
|
# FAILFAST causes us to abort early if the data doesn't match
|
|
|
|
# the given schema. Without this there was as very annoying
|
|
|
|
# problem where dataframe.collect() would return an empty set.
|
|
|
|
frame = spark.read.json(rows_path, schema, mode="FAILFAST")
|
|
|
|
return frame
|
|
|
|
|
|
|
|
|
2019-06-04 20:32:25 +03:00
|
|
|
@pytest.fixture()
|
|
|
|
def spark():
|
|
|
|
spark_session = SparkSession.builder.appName("addons_daily_tests").getOrCreate()
|
|
|
|
return spark_session
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def main_summary(spark):
|
|
|
|
return load_test_data("main_summary", spark)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture()
|
|
|
|
def events(spark):
|
|
|
|
return load_test_data("events", spark)
|
|
|
|
|
|
|
|
|
2019-06-04 21:11:28 +03:00
|
|
|
@pytest.fixture()
|
|
|
|
def search_clients_daily(spark):
|
|
|
|
return load_test_data("search_clients_daily", spark).filter(
|
|
|
|
"submission_date_s3 = '{}'".format(BASE_DATE)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-05-31 02:18:56 +03:00
|
|
|
@pytest.fixture()
|
|
|
|
def addons_expanded(main_summary):
|
|
|
|
return expand_addons(main_summary)
|
|
|
|
|
|
|
|
|
2019-05-31 21:08:46 +03:00
|
|
|
@pytest.fixture()
|
|
|
|
def main_summary_day(main_summary):
|
|
|
|
return main_summary.filter("submission_date_s3 = '{}'".format(BASE_DATE))
|
|
|
|
|
|
|
|
|
2019-05-31 02:18:56 +03:00
|
|
|
@pytest.fixture()
|
|
|
|
def addons_expanded_day(addons_expanded):
|
|
|
|
return addons_expanded.filter("submission_date_s3 = '{}'".format(BASE_DATE))
|
|
|
|
|
|
|
|
|
2019-06-01 00:21:35 +03:00
|
|
|
def test_addon_names(addons_expanded_day, spark):
|
|
|
|
output = df_to_json(get_top_addon_names(addons_expanded_day))
|
|
|
|
expected = [
|
|
|
|
{
|
|
|
|
"addon_id": u"baidu-code-update@mozillaonline.com",
|
|
|
|
"name": u"Baidu Search Update",
|
|
|
|
},
|
|
|
|
{"addon_id": u"screenshots@mozilla.org", "name": u"Firefox Screenshots"},
|
|
|
|
{"addon_id": u"non-system-addon1", "name": u"Non systemn Addon 1"},
|
|
|
|
{
|
|
|
|
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"name": u"hotfix-update-xpi-intermediate",
|
|
|
|
},
|
|
|
|
{"addon_id": u"fxmonitor@mozilla.org", "name": u"Firefox Monitor"},
|
|
|
|
{"addon_id": u"non-system-addon2", "name": u"Non System Addon 2"},
|
|
|
|
{"addon_id": u"formautofill@mozilla.org", "name": u"Form Autofill"},
|
|
|
|
{"addon_id": u"webcompat@mozilla.org", "name": u"Web Compat"},
|
|
|
|
]
|
|
|
|
assert output == expected
|
|
|
|
|
|
|
|
|
2019-05-31 21:08:46 +03:00
|
|
|
def test_browser_metrics(addons_expanded_day, spark):
|
2019-05-31 02:18:56 +03:00
|
|
|
"""
|
|
|
|
Given a dataframe of some actual sampled data, ensure that
|
|
|
|
the get_pct_tracking_enabled outputs the correct dataframe
|
|
|
|
:param addons_expanded: pytest fixture defined above
|
|
|
|
:return: assertion whether the expected output indeed matches the true output
|
|
|
|
"""
|
2019-05-31 21:08:46 +03:00
|
|
|
output = df_to_json(get_browser_metrics(addons_expanded_day))
|
|
|
|
expected = [
|
|
|
|
{
|
|
|
|
"addon_id": u"baidu-code-update@mozillaonline.com",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"screenshots@mozilla.org",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon1",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
2019-05-31 21:08:46 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"fxmonitor@mozilla.org",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon2",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
2019-05-31 21:08:46 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"formautofill@mozilla.org",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"webcompat@mozilla.org",
|
|
|
|
"avg_bookmarks": None,
|
|
|
|
"avg_tabs": None,
|
|
|
|
"avg_toolbox_opened_count": None,
|
|
|
|
"avg_uri": 33.0,
|
|
|
|
"pct_w_tracking_prot_enabled": 0.0,
|
|
|
|
},
|
|
|
|
]
|
2019-05-31 02:18:56 +03:00
|
|
|
assert output == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_user_demo_metrics(addons_expanded_day, spark):
|
|
|
|
output = df_to_json(get_user_demo_metrics(addons_expanded_day))
|
|
|
|
expected = [
|
|
|
|
{
|
|
|
|
"addon_id": u"baidu-code-update@mozillaonline.com",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"screenshots@mozilla.org",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon1",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
2019-05-31 02:18:56 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"fxmonitor@mozilla.org",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon2",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
2019-05-31 02:18:56 +03:00
|
|
|
{
|
|
|
|
"addon_id": u"formautofill@mozilla.org",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"webcompat@mozilla.org",
|
|
|
|
"country_dist": {u"GB": 1.0},
|
|
|
|
"os_dist": {u"Windows_NT": 1.0},
|
|
|
|
},
|
|
|
|
]
|
|
|
|
print("output", output)
|
|
|
|
print("expected", expected)
|
|
|
|
assert output == expected
|
|
|
|
|
|
|
|
|
|
|
|
def test_trend_metrics(addons_expanded, spark):
|
|
|
|
output = df_to_json(get_trend_metrics(addons_expanded, BASE_DATE))
|
|
|
|
expected_output = [
|
|
|
|
{
|
2019-06-04 03:24:08 +03:00
|
|
|
"addon_id": "baidu-code-update@mozillaonline.com",
|
2019-05-31 02:18:56 +03:00
|
|
|
"mau": 1,
|
|
|
|
"wau": 1,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
2019-05-31 02:18:56 +03:00
|
|
|
},
|
|
|
|
{
|
2019-06-04 03:24:08 +03:00
|
|
|
"addon_id": "tls13-version-fallback-rollout-bug1462099@mozilla.org",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
2019-05-31 02:18:56 +03:00
|
|
|
"dau": None,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau_prop": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "screenshots@mozilla.org",
|
|
|
|
"mau": 2,
|
|
|
|
"wau": 1,
|
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "non-system-addon1",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": 1,
|
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "firefox@getpocket.com",
|
2019-05-31 02:18:56 +03:00
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau": None,
|
|
|
|
"dau_prop": None,
|
2019-05-31 02:18:56 +03:00
|
|
|
},
|
|
|
|
{
|
2019-06-04 03:24:08 +03:00
|
|
|
"addon_id": "hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": 1,
|
2019-05-31 02:18:56 +03:00
|
|
|
"dau": 1,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "fxmonitor@mozilla.org",
|
2019-05-31 02:18:56 +03:00
|
|
|
"mau": 1,
|
|
|
|
"wau": 1,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "aushelper@mozilla.org",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
|
|
|
"dau": None,
|
|
|
|
"dau_prop": None,
|
2019-05-31 02:18:56 +03:00
|
|
|
},
|
|
|
|
{
|
2019-06-04 03:24:08 +03:00
|
|
|
"addon_id": "onboarding@mozilla.org",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
2019-05-31 02:18:56 +03:00
|
|
|
"dau": None,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau_prop": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "activity-stream@mozilla.org",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
|
|
|
"dau": None,
|
|
|
|
"dau_prop": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "non-system-addon2",
|
|
|
|
"mau": 1,
|
|
|
|
"wau": 1,
|
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "followonsearch@mozilla.com",
|
2019-05-31 02:18:56 +03:00
|
|
|
"mau": 1,
|
|
|
|
"wau": None,
|
2019-06-04 03:24:08 +03:00
|
|
|
"dau": None,
|
|
|
|
"dau_prop": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "formautofill@mozilla.org",
|
|
|
|
"mau": 2,
|
|
|
|
"wau": 1,
|
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "webcompat@mozilla.org",
|
|
|
|
"mau": 2,
|
|
|
|
"wau": 1,
|
|
|
|
"dau": 1,
|
|
|
|
"dau_prop": 1.0,
|
2019-05-31 02:18:56 +03:00
|
|
|
},
|
|
|
|
]
|
2019-06-04 03:24:08 +03:00
|
|
|
|
2019-05-31 02:18:56 +03:00
|
|
|
assert output == expected_output
|
|
|
|
|
|
|
|
|
2019-06-01 00:21:35 +03:00
|
|
|
def test_top_ten_coinstalls(addons_expanded_day, spark):
|
2019-05-31 02:18:56 +03:00
|
|
|
"""
|
|
|
|
Given a dataframe of some actual sampled data, ensure that
|
|
|
|
the get_pct_tracking_enabled outputs the correct dataframe
|
|
|
|
:param main_summary_tto: pytest fixture defined above, sample data from main_summary
|
|
|
|
:return: assertion whether the expected output indeed matches the true output
|
|
|
|
"""
|
2019-06-01 00:21:35 +03:00
|
|
|
output = df_to_json(get_top_10_coinstalls(addons_expanded_day))
|
|
|
|
expected = [
|
|
|
|
{
|
|
|
|
"addon_id": u"baidu-code-update@mozillaonline.com",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon2",
|
|
|
|
u"1": u"non-system-addon1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"screenshots@mozilla.org",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
u"1": u"non-system-addon1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon1",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon1",
|
|
|
|
u"1": u"non-system-addon2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon1",
|
|
|
|
u"1": u"non-system-addon2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"fxmonitor@mozilla.org",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon1",
|
|
|
|
u"1": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"non-system-addon2",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon2",
|
|
|
|
u"1": u"non-system-addon1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"formautofill@mozilla.org",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon1",
|
|
|
|
u"1": u"non-system-addon2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": u"webcompat@mozilla.org",
|
|
|
|
"top_10_coinstalls": {
|
|
|
|
u"0": u"non-system-addon1",
|
|
|
|
u"1": u"non-system-addon2",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
]
|
2019-05-31 02:18:56 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_engagement_metrics(addons_expanded_day, main_summary_day, spark):
|
|
|
|
"""
|
|
|
|
Given a dataframe of some actual sampled data, ensure that
|
|
|
|
the get_pct_tracking_enabled outputs the correct dataframe
|
|
|
|
:param addons_expanded: pytest fixture defined above
|
|
|
|
:return: assertion whether the expected output indeed matches the true output
|
|
|
|
"""
|
2019-05-31 21:08:46 +03:00
|
|
|
output = df_to_json(get_engagement_metrics(addons_expanded_day, main_summary_day))
|
2019-05-31 02:18:56 +03:00
|
|
|
expected_output = [
|
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"baidu-code-update@mozillaonline.com",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"screenshots@mozilla.org",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"non-system-addon1",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
2019-05-31 02:18:56 +03:00
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"hotfix-update-xpi-intermediate@mozilla.com",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"fxmonitor@mozilla.org",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
2019-06-01 00:21:35 +03:00
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"non-system-addon2",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
2019-05-31 02:18:56 +03:00
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"formautofill@mozilla.org",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"active_hours": 0.18194444444444444,
|
|
|
|
"addon_id": u"webcompat@mozilla.org",
|
|
|
|
"avg_time_total": 747.0,
|
|
|
|
"disabled": None,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
assert output == expected_output
|
2019-06-04 20:32:25 +03:00
|
|
|
|
|
|
|
|
|
|
|
def test_install_flows(events):
|
|
|
|
output = df_to_json(install_flow_events(events))
|
2019-06-04 23:51:54 +03:00
|
|
|
print("OUT", output)
|
2019-06-04 20:32:25 +03:00
|
|
|
expected_output = [
|
|
|
|
{
|
|
|
|
"addon_id": "screenshots@mozilla.org",
|
2019-06-04 23:51:54 +03:00
|
|
|
"installs": {"amo": 2, "unknown": 0},
|
|
|
|
"download_times": {"amo": 584.5, "unknown": 0.0},
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": {"system-addon": 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "fxmonitor@mozilla.org",
|
|
|
|
"installs": None,
|
2019-06-04 23:51:54 +03:00
|
|
|
"download_times": None,
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": {"system-addon": 1},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "jid1-h4Ke2h5q31uuK7@jetpack",
|
2019-06-04 23:51:54 +03:00
|
|
|
"installs": {"amo": 1, "unknown": 0},
|
|
|
|
"download_times": {"amo": 1704.0, "unknown": 0.0},
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "{87e997f4-ae0e-42e6-a780-ff73977188c5}",
|
2019-06-04 23:51:54 +03:00
|
|
|
"installs": {"amo": 1, "unknown": 0},
|
|
|
|
"download_times": {"amo": 3015.0, "unknown": 0.0},
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "{08cc31c0-b1cb-461c-8ba2-95edd9e76a02}",
|
2019-06-04 23:51:54 +03:00
|
|
|
"installs": {"amo": 1, "unknown": 0},
|
|
|
|
"download_times": {"amo": 998.0, "unknown": 0.0},
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": None,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "Directions_Found_mVBuOLkFzz@www.directionsfoundnt.com",
|
2019-06-04 23:51:54 +03:00
|
|
|
"installs": {"amo": 0, "unknown": 1},
|
|
|
|
"download_times": {"amo": 0.0, "unknown": 572.0},
|
2019-06-04 20:32:25 +03:00
|
|
|
"uninstalls": None,
|
|
|
|
},
|
|
|
|
]
|
2019-06-04 21:11:28 +03:00
|
|
|
assert output == expected_output
|
|
|
|
|
|
|
|
|
|
|
|
def test_searches_and_ads(search_clients_daily, addons_expanded_day, spark):
|
|
|
|
output = df_to_json(get_search_metrics(search_clients_daily, addons_expanded_day))
|
|
|
|
print("OUT", output)
|
|
|
|
expected_output = [
|
|
|
|
{
|
|
|
|
"addon_id": "baidu-code-update@mozillaonline.com",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "screenshots@mozilla.org",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "non-system-addon1",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "hotfix-update-xpi-intermediate@mozilla.com",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "fxmonitor@mozilla.org",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "non-system-addon2",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "formautofill@mozilla.org",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
{
|
|
|
|
"addon_id": "webcompat@mozilla.org",
|
2019-06-05 00:46:18 +03:00
|
|
|
"search_with_ads": {"google": 3},
|
2019-06-05 00:57:13 +03:00
|
|
|
"ad_click": {"google": 0},
|
|
|
|
"organic_searches": {"google": 0},
|
2019-06-05 00:46:18 +03:00
|
|
|
"sap_searches": {"google": 10},
|
|
|
|
"tagged_sap_searches": {"google": 10},
|
2019-06-04 21:11:28 +03:00
|
|
|
},
|
|
|
|
]
|
|
|
|
|
|
|
|
assert output == expected_output
|