feat(nimbus): Update to mozilla-nimbus-schemas 2024.11.5 (#11746)
Because: - mozilla-nimbus-schemas v2024.11.5 has been released; - mozilla-nimbus-schemas v2024.11.4 added strict and lax schemas for Desktop Nimbus experiments; and - the updated Desktop schema now has the correct feature placeholder feature ID. This commit: - updates us to mozilla-nimbus-schemas v2024.11.5; - updates our tests to use the appropriate schema validators in tests; - removes validation against these schemas from the v8 API tests. Fixes #11745
This commit is contained in:
Родитель
3a75cfaf87
Коммит
7a8621b511
|
@ -314,6 +314,10 @@ class Application(models.TextChoices):
|
|||
)
|
||||
DEMO_APP = (APPLICATION_CONFIG_DEMO_APP.slug, APPLICATION_CONFIG_DEMO_APP.name)
|
||||
|
||||
@staticmethod
|
||||
def is_sdk(application):
|
||||
return application != Application.DESKTOP
|
||||
|
||||
@staticmethod
|
||||
def is_mobile(application):
|
||||
return application in (
|
||||
|
|
|
@ -4,7 +4,10 @@ from typing import Any
|
|||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from mozilla_nimbus_schemas.experiments import NimbusExperiment as NimbusExperimentSchema
|
||||
from mozilla_nimbus_schemas.experiments import (
|
||||
DesktopAllVersionsNimbusExperiment,
|
||||
SdkNimbusExperiment,
|
||||
)
|
||||
from parameterized import parameterized
|
||||
|
||||
from experimenter.base.tests.factories import LocaleFactory
|
||||
|
@ -21,6 +24,19 @@ from experimenter.experiments.tests.factories import (
|
|||
class TestNimbusExperimentSerializer(TestCase):
|
||||
maxDiff = None
|
||||
|
||||
@classmethod
|
||||
def _validate_experiment_schema(
|
||||
cls,
|
||||
application: NimbusExperiment.Application,
|
||||
experiment_data: dict[str, Any],
|
||||
):
|
||||
if NimbusExperiment.Application.is_sdk(application):
|
||||
schema = SdkNimbusExperiment
|
||||
else:
|
||||
schema = DesktopAllVersionsNimbusExperiment
|
||||
|
||||
schema.model_validate(experiment_data)
|
||||
|
||||
def test_expected_schema_with_desktop(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -145,7 +161,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
branches_data,
|
||||
)
|
||||
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
DesktopAllVersionsNimbusExperiment.model_validate(serializer.data)
|
||||
|
||||
def test_expected_schema_with_desktop_with_non_default_fxlabs_fields(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
|
@ -261,7 +277,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
experiment.save()
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["branches"][0]["features"], [])
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
self._validate_experiment_schema(application, serializer.data)
|
||||
|
||||
def test_serializers_with_empty_feature_value(self):
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -281,7 +297,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
)
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["branches"][0]["features"][0]["value"], {})
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
DesktopAllVersionsNimbusExperiment.model_validate(serializer.data)
|
||||
|
||||
def test_serializer_with_branch_invalid_feature_value(self):
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -328,7 +344,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
NimbusExperiment.APPLICATION_CONFIGS[application].app_name,
|
||||
)
|
||||
self.assertEqual(serializer.data["appId"], channel_app_id)
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
self._validate_experiment_schema(application, serializer.data)
|
||||
|
||||
def test_serializer_outputs_targeting(self):
|
||||
experiment = NimbusExperimentFactory.create_with_lifecycle(
|
||||
|
@ -339,7 +355,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
)
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["targeting"], experiment.targeting)
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
DesktopAllVersionsNimbusExperiment.model_validate(serializer.data)
|
||||
|
||||
def test_serializer_outputs_empty_targeting(self):
|
||||
experiment = NimbusExperimentFactory.create_with_lifecycle(
|
||||
|
@ -352,7 +368,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["targeting"], "true")
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
SdkNimbusExperiment.model_validate(serializer.data)
|
||||
|
||||
def test_localized_desktop(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
|
@ -374,7 +390,7 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
|
||||
self.assertIn("localizations", serializer.data)
|
||||
self.assertEqual(serializer.data["localizations"], json.loads(TEST_LOCALIZATIONS))
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
DesktopAllVersionsNimbusExperiment.model_validate(serializer.data)
|
||||
|
||||
def test_multiple_locales(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
|
|
|
@ -4,7 +4,6 @@ from typing import Any
|
|||
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
from mozilla_nimbus_schemas.experiments import NimbusExperiment as NimbusExperimentSchema
|
||||
from parameterized import parameterized
|
||||
|
||||
from experimenter.base.tests.factories import LocaleFactory
|
||||
|
@ -97,8 +96,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
branches_data,
|
||||
)
|
||||
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_expected_schema_with_desktop_with_non_default_fxlabs_fields(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -214,7 +211,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
experiment.save()
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["branches"][0]["features"], [])
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_serializers_with_empty_feature_value(self):
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -234,7 +230,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
)
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["branches"][0]["features"][0]["value"], {})
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_serializer_with_branch_invalid_feature_value(self):
|
||||
application = NimbusExperiment.Application.DESKTOP
|
||||
|
@ -281,7 +276,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
NimbusExperiment.APPLICATION_CONFIGS[application].app_name,
|
||||
)
|
||||
self.assertEqual(serializer.data["appId"], channel_app_id)
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_serializer_outputs_targeting(self):
|
||||
experiment = NimbusExperimentFactory.create_with_lifecycle(
|
||||
|
@ -292,7 +286,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
)
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["targeting"], experiment.targeting)
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_serializer_outputs_empty_targeting(self):
|
||||
experiment = NimbusExperimentFactory.create_with_lifecycle(
|
||||
|
@ -305,7 +298,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
|
||||
serializer = NimbusExperimentSerializer(experiment)
|
||||
self.assertEqual(serializer.data["targeting"], "true")
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_localized_desktop(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
|
@ -328,7 +320,6 @@ class TestNimbusExperimentSerializer(TestCase):
|
|||
|
||||
self.assertIn("localizations", serializer.data)
|
||||
self.assertEqual(serializer.data["localizations"], json.loads(TEST_LOCALIZATIONS))
|
||||
NimbusExperimentSchema.model_validate(serializer.data)
|
||||
|
||||
def test_multiple_locales(self):
|
||||
locale_en_us = LocaleFactory.create(code="en-US")
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# This file is automatically @generated by Poetry 1.8.3 and should not be changed by hand.
|
||||
# This file is automatically @generated by Poetry 1.8.4 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "amqp"
|
||||
|
@ -1695,13 +1695,13 @@ testing = ["coverage", "isort", "jsonschema", "mypy", "pytest", "pytest-black",
|
|||
|
||||
[[package]]
|
||||
name = "mozilla-nimbus-schemas"
|
||||
version = "2024.11.2"
|
||||
version = "2024.11.5"
|
||||
description = "Schemas used by Mozilla Nimbus and related projects."
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.10"
|
||||
files = [
|
||||
{file = "mozilla_nimbus_schemas-2024.11.2-py3-none-any.whl", hash = "sha256:451eab2a002c98ec1731708abcf60960ee5170a5a8ee27717f1326a994ea6853"},
|
||||
{file = "mozilla_nimbus_schemas-2024.11.2.tar.gz", hash = "sha256:9d8463f97d48c5153a4119aa573226db84fb518e7fa8a26d8923e537bc741d5b"},
|
||||
{file = "mozilla_nimbus_schemas-2024.11.5-py3-none-any.whl", hash = "sha256:4b4e6835b1e8e142f79a7543238a7f8b9a5c5abd7178cb86d9f266f9eee5deb5"},
|
||||
{file = "mozilla_nimbus_schemas-2024.11.5.tar.gz", hash = "sha256:83de58bea9d56be679ad0bb174c5769ba5f076ef25e566868b4582ddb3867b01"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
@ -3282,4 +3282,4 @@ files = [
|
|||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "9960b8299f3ba3c0d959b4421bed8df7a09f1170f791a58c9709048bd9f7b7e3"
|
||||
content-hash = "f9d0c7851c4de4588e02329be2b7670f34a459bc2c2277de3da8dd84c2ce9231"
|
||||
|
|
|
@ -64,7 +64,7 @@ djangorestframework-dataclasses = "^1.3.0"
|
|||
graphene-django = "^3.2.0"
|
||||
pyright = "^1.1.291"
|
||||
django-types = "^0.19.1"
|
||||
mozilla-nimbus-schemas = "2024.11.2"
|
||||
mozilla-nimbus-schemas = "2024.11.5"
|
||||
mozilla-metric-config-parser = "^2024.10.2"
|
||||
django-redis = "^5.4.0"
|
||||
fontawesomefree = "6.6.0"
|
||||
|
|
Загрузка…
Ссылка в новой задаче